<template>
  <!-- 创建运单后的弹框 -->
  <div :class="[!Typeinformation ? 'creation' : 'creation_one']">
    <div class="header" v-if="!Typeinformation">
      <span class="order-title" @click="activeName = 0">
        <span v-show="allorderType == 'add'"> 创建运单</span>
        <span v-show="allorderType == 'onlyread' || allorderType == 'modify'"
          >编辑运单</span
        >
        <span v-show="allorderType == 'transfer_order'">创建转单</span>
      </span>
      <div class="order-right">
        <span class="order-close">
          <i
            class="el-icon-close"
            @click="orderclose()"
            style="color: #9f9f9f"
          />
        </span>
      </div>
    </div>
    <el-dialog
      :close-on-click-modal="false"
      :visible.sync="paymentQrcodeVisible"
      width="20%"
      center
      append-to-body
      :show-close="false"
    >
      <template slot="title"
        ><span
          class="icon iconfont icon-weixin"
          style="color: #28c445; margin-right: 10px; font-size: 20px"
        ></span
        >微信支付</template
      >
      <el-image v-if="!paySuccess" :src="qrcodeUrl" fit="cover"></el-image>
      <el-result v-else icon="success" title="支付成功"> </el-result>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="closeQrcode">关 闭</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="退款"
      :close-on-click-modal="false"
      :visible.sync="refundVisible"
      width="40%"
      center
      append-to-body
    >
      <el-form label-width="100px">
        <el-form-item label="退款金额">
          {{ alltotal_cost }}
        </el-form-item>
        <el-form-item label="退款备注" required>
          <el-input
            type="textarea"
            style="width: 400px"
            v-model="refundValue.remark"
          ></el-input>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="refundVisible = false" style="margin-right: 20px"
          >关闭</el-button
        >
        <el-popover placement="top" width="160" v-model="refundConfirmVisible">
          <p>确定要退款吗？</p>
          <div style="text-align: right; margin: 0">
            <el-button
              size="mini"
              type="text"
              @click="refundConfirmVisible = false"
              >取消</el-button
            >
            <el-button type="primary" size="mini" @click="confirmRefund"
              >确定</el-button
            >
          </div>
          <el-button slot="reference" type="primary">确定</el-button>
        </el-popover>
      </span>
    </el-dialog>
    <div>
      <notify
        v-if="notifyType"
        :noTifyData="noTifyData"
        :key="noTifyData"
      ></notify>
    </div>
    <BackMoney
      v-if="backDialogVisible"
      :dialogVisible="backDialogVisible"
      @close="handleCloseBackDialog"
      origin="waybill"
      :waybillId="id"
      :payStatus="ruleForm.pay_status"
      :key="ruleForm.pay_status"
    ></BackMoney>
    <SelectAddress
      v-if="addressDialogVisible"
      :dialogVisible="addressDialogVisible"
      @close="handleCloseAddressDialog"
      @ok="handleAddressDialogOk"
    ></SelectAddress>
    <div class="footer" v-permission="['waybill_update']">
      <div style="margin: 0 auto">
        <el-button
          v-if="
            showPaymentBtn &&
            ruleForm.pay_status === '0' &&
            allorderType == 'onlyread' &&
            activeName === 0
          "
          id="openPayment"
          @click="openPayment"
          type="primary"
          data-tracker="P2-17"
          :loading="toPaymentLoading"
          >收款</el-button
        >
        <el-button
          @click="handleReturnMoney"
          type="primary"
          v-if="
            ruleForm.pay_status !== '0' &&
            allorderType == 'onlyread' &&
            activeName === 0
          "
          >退款</el-button
        >
        <el-button
          @click="saveadd('ruleForm')"
          id="orderSave"
          v-if="allorderType == 'add'"
          type="success"
          data-tracker="P3-29"
          v-preventReClick
          key="1"
          :loading="addLoading"
          >保存</el-button
        >
        <el-button
          @click="upadateadd('ruleForm')"
          id="orderSave"
          type="success"
          v-if="allorderType == 'modify' && activeName === 0"
          data-tracker="P4-45"
          v-preventReClick
          key="2"
          :loading="updateLoading"
          >保存</el-button
        >
        <el-button
          @click="saveadd('ruleForm')"
          id="orderSave"
          type="success"
          v-if="allorderType == 'transfer_order'"
          data-tracker="P2-16"
          v-preventReClick
          key="3"
          >转单</el-button
        >
        <el-button
          id="orderCancel"
          @click="changedclose()"
          type="info"
          v-if="allorderType == 'onlyread' && activeName === 0"
          data-tracker="P4-44"
          v-preventReClick
          v-permission="'waybill_update'"
          key="4"
          >编辑</el-button
        >
        <el-button
          id="orderCancel"
          @click="orderclose()"
          type="primary"
          data-tracker="P3-30"
          v-if="!Typeinformation"
          >取消</el-button
        >
        <!-- <el-button
          v-if="ruleForm.pay_status === '1'"
          type="danger"
          @click="refundVisible = true"
          >退款</el-button
        > -->
      </div>
    </div>

    <div
      :class="[!Typeinformation ? 'article' : 'article_one']"
      v-if="activeName === 0"
    >
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
        :disabled="disabled_value"
      >
        <!-- 运单号和运单备注 -->
        <div class="order-content">
          <el-col :span="6">
            <el-form-item label="运单号">
              <el-input
                id="waybill_no"
                v-model="ruleForm.waybill_number"
                maxlength="20"
                placeholder="默认自动生成"
                :disabled="setting_list_type"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item
              label="所属客户"
              prop="customer_id"
              v-if="this.localStorage_id == 0"
            >
              <el-select
                id="customer_down"
                filterable
                remote
                reserve-keyword
                :remote-method="searchCustomerList"
                v-model="ruleForm.customer_id"
                @change="selectedCustomer"
                style="width: 100%"
                :disabled="waybill_order_status"
              >
                <el-option
                  id="customer"
                  v-for="item in clientList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="所属客户"
              prop="customer_id"
              v-if="this.localStorage_id == 1"
            >
              <el-select
                id="customer_down"
                v-model="ruleForm.customer_id"
                filterable
                placeholder="请选择"
                :disabled="true"
                style="width: 100%"
              >
                <el-option
                  id="customer"
                  v-for="item2 in clientList"
                  :key="item2.id"
                  :label="item2.name"
                  :value="item2.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="承运类型" prop="waybill_product_type">
              <el-select
                id="transport_product_down"
                v-model="ruleForm.waybill_product_type"
                placeholder="请选择"
                @change="selectTransportsType"
                style="width: 100%"
                :disabled="waybill_order_status||(isZto && allorderType == 'modify')"
              >
                <el-option
                  id="transport_product"
                  v-for="item in carrier_type"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                  :disabled="item.id=='43' && allorderType == 'modify'"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="运单时效">
              <el-input
                id="estimated_timeliness"
                v-model="ruleForm.valid_time"
                style="width: 80%; margin-right: 5px"
                :disabled="waybill_order_status"
              ></el-input
              >小时
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="ruleForm.type == '0'">
            <el-form-item label="温层">
              <el-select
                v-model="ruleForm.thermosphere"
                placeholder="请选择"
                :disabled="true"
                style="width: 100%"
              >
                <el-option
                  v-for="item in thermosphere"
                  :key="item.item_code"
                  :label="item.item_name"
                  :value="item.item_code"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="ruleForm.type == '2' || ruleForm.type == ''">
            <el-form-item label="温层">
              <el-select
                id="thermosphere_down"
                v-model="ruleForm.thermosphere"
                placeholder="请选择"
                style="width: 100%"
                :disabled="waybill_order_status"
              >
                <el-option
                  id="thermosphere"
                  v-for="item in thermosphere"
                  :key="item.item_code"
                  :label="item.item_name"
                  :value="item.item_code"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="isZto?'预约揽收时间':'提货时间'" prop="value1" label-width="110px">
              <el-date-picker
                id="collect_time"
                v-model="ruleForm.value1"
                type="datetime"
                @change="handleChangeStartTime"
                value-format="timestamp"
                placeholder="选择日期时间"
                default-time="12:00:00"
                style="width: 100%"
                :disabled="waybill_order_status"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="是否投保">
              <el-radio-group
                v-model="ruleForm.insure_value"
                :disabled="waybill_order_status"
              >
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="创建时间">
              <el-date-picker
                v-model="create_time"
                type="datetime"
                style="width: 80%"
                value-format="timestamp"
                placeholder="选择日期时间"
                default-time="12:00:00"
                :disabled="true"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </div>
        <!-- 发货人收货人接口 -->
        <div class="order-cargo">
          <!-- 发货人 -->
          <div class="order-shiper">
            <el-row style="padding: 0px 0px 10px 0px">
              <el-col :span="24">
                <div class="order-shiper-header">
                  <span>发货方</span>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="20">
                <el-form-item label="发货人:" prop="sender.name">
                  <el-select
                    id="sender_down"
                    v-model="ruleForm.sender.name"
                    filterable
                    remote
                    default-first-option
                    value-key="id"
                    placeholder=""
                    :remote-method="searchConsignorList"
                    @change="selectedConsignor"
                    @blur.native.capture="sender_selected_data($event)"
                    style="width: 100%"
                    v-if="ruleForm.customer_id != ''"
                    :disabled="waybill_order_status"
                  >
                    <el-option
                      id="sender"
                      v-for="item in consignorList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                  <el-input
                    v-model="ruleForm.sender.name"
                    :disabled="waybill_order_status"
                    v-else
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="20">
                <el-form-item label="手机号:" prop="sender.phone">
                  <el-input
                    id="sender_phone"
                    v-model.trim="ruleForm.sender.phone"
                    :disabled="waybill_order_status"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="20">
                <el-form-item label="发货公司:" prop="sender.company">
                  <el-input
                    id="sender_company"
                    v-model="ruleForm.sender.company"
                    @blur.native.capture="forwarding_unit($event)"
                    :disabled="waybill_order_status"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="20">
                <el-form-item label="详细地址:" prop="sender.address">
                  <el-input
                    id="sender_address"
                    v-model="ruleForm.sender.address"
                    @blur="FuzhiChange"
                    :disabled="waybill_order_status"
                  >
                    <div
                      slot="suffix"
                      style="cursor: pointer"
                      @click="handleShowAddressDialog('sender')"
                    >
                      <i
                        style="
                          font-size: 15px;
                          color: darkorange;
                          padding-right: 3px;
                        "
                        class="el-icon-location-outline"
                      ></i>
                    </div>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="20">
                <el-form-item label="发货地址:" prop="addressList">
                  <el-cascader
                    style="width: 100%"
                    v-model="ruleForm.addressList"
                    ref="editCascader"
                    placeholder=""
                    :options="addresssequence"
                    clearable
                    filterable
                    @clear="
                      ruleForm.addressList = [];
                      ruleForm.sender.province_name = '';
                      ruleForm.sender.city_name = '';
                      ruleForm.sender.district_name = '';
                    "
                    @change="shiphandleChange($event)"
                    :props="{
                      value: 'id',
                      label: 'name',
                      children: 'next_level_data',
                    }"
                    :disabled="waybill_order_status"
                  ></el-cascader>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="20"> </el-col>
            </el-row>
          </div>
          <!-- 收货人 -->
          <div class="order-delivery">
            <el-row style="padding: 0px 0px 10px 0px">
              <el-col :span="24">
                <div class="order-shiper-header">
                  <span>收货方</span>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="20">
                <el-form-item label="收货人:" prop="receiver.name">
                  <el-select
                    id="receiver_down"
                    v-model.trim="ruleForm.receiver.name"
                    filterable
                    remote
                    reserve-keyword
                    default-first-option
                    :remote-method="pageConsigneeInterface"
                    @change="ConsigneeConsignor"
                    @blur.native.capture="receiver_selected_data($event)"
                    style="width: 100%"
                    v-if="ruleForm.customer_id != ''"
                    :disabled="waybill_order_status"
                  >
                    <el-option
                      id="receiver"
                      v-for="item in ConsigneeInterfaceList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                  <el-input
                    v-model="ruleForm.receiver.name"
                    :disabled="waybill_order_status"
                    v-else
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="20">
                <el-form-item label="手机号:" prop="receiver.phone">
                  <el-input
                    id="receiver_phone"
                    v-model.trim="ruleForm.receiver.phone"
                    :disabled="waybill_order_status"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="20">
                <el-form-item label="收货公司:" prop="receiver.company">
                  <el-input
                    id="receiver_company"
                    v-model="ruleForm.receiver.company"
                    :disabled="waybill_order_status"
                    maxlength="32"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="20">
                <el-form-item label="详细地址:" prop="receiver.address">
                  <el-input
                    id="receiver_address"
                    v-model="ruleForm.receiver.address"
                    :disabled="waybill_order_status"
                    @blur="FuzhiReceiverChange"
                  >
                    <div
                      slot="suffix"
                      style="cursor: pointer"
                      @click="handleShowAddressDialog('receiver')"
                    >
                      <i
                        style="
                          font-size: 15px;
                          color: darkorange;
                          padding-right: 3px;
                        "
                        class="el-icon-location-outline"
                      ></i>
                    </div>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="20">
                <el-form-item label="收货地址:" prop="receiverList">
                  <el-cascader
                    style="width: 100%"
                    v-model="ruleForm.receiverList"
                    placeholder=""
                    @change="rechandleChange($event)"
                    :options="addresssequence"
                    clearable
                    filterable
                    @clear="
                      ruleForm.receiverList = [];
                      ruleForm.receiver.province_name = '';
                      ruleForm.receiver.city_name = '';
                      ruleForm.receiver.district_name = '';
                    "
                    :props="{
                      value: 'id',
                      label: 'name',
                      children: 'next_level_data',
                    }"
                    :disabled="waybill_order_status"
                  ></el-cascader>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </div>
        <!-- 货物信息  -->
        <div class="order-information">
          <div class="order-shiper-header">
            <span>货物信息</span>
          </div>
          <div class="order-shiper-warp">
            <el-table
              ref="singleTable"
              :data="ruleForm.goods.filter(item=>item.is_settlement_info!==1)"
              highlight-current-row
              style="width: 100%"
              border
              :key="keyType"
            >
              <el-table-column width="50">
                <template slot="header" slot-scope="scope">
                  <span @click="addShiper(scope)" style="font-size: 20px"
                    >+</span
                  >
                </template>
                <template slot-scope="scope">
                  <div class="remodername">
                    <div class="number">{{ scope.$index + 1 }}</div>
                    <div
                      class="remodercenter el-icon-minus"
                      @click="reduce(scope.$index)"
                    ></div>
                  </div>
                </template>
              </el-table-column>
              <!-- 需要投保的时候货物名称是必填项 -->
              <el-table-column
                property="name"
                label="货物名称"
                width="180"
                :key="Math.random()"
                v-if="
                  ruleForm.customer_id == 18323 || ruleForm.insure_value == 1 || isZto
                "
              >
                <template slot="header">
                  <span style="color: red">*货物名称</span>
                </template>
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'goods.' + scope.$index + '.name'"
                    :rules="rules.name"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-input
                      v-model="scope.row.name"
                      :disabled="waybill_order_status"
                    >
                    </el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <!-- 货物名称非必填 -->
              <el-table-column
                property="name"
                label="货物名称"
                width="180"
                v-else
              >
                <template slot="header">
                  <span>货物名称</span>
                </template>
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.name"
                    :disabled="waybill_order_status"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                property="goods_no"
                label="产品编码"
                prop="goods_no"
                width="180"
                v-if="ruleForm.customer_id == 18323"
              >
                <template slot="header">
                  <span style="color: red">*产品编码</span>
                </template>
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'goods.' + scope.$index + '.goods_no'"
                    :rules="rules.goods_no"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-input
                      v-model="scope.row.goods_no"
                      :disabled="waybill_order_status"
                    ></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                property="product_batch"
                label="产品批号"
                width="100"
                v-if="ruleForm.customer_id == 18323"
              >
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.product_batch"
                    :disabled="waybill_order_status"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                property="product_valid_period"
                label="产品有效期"
                width="210"
                v-if="ruleForm.customer_id == 18323"
              >
                <template slot-scope="scope">
                  <el-date-picker
                    style="width: 180px"
                    v-model="scope.row.product_valid_period"
                    type="datetime"
                    value-format="timestamp"
                    placeholder="选择日期时间"
                    default-time="12:00:00"
                    :disabled="waybill_order_status"
                  >
                  </el-date-picker>
                </template>
              </el-table-column>
              <el-table-column
                property="shipment_quantity"
                label="发货数量"
                width="105"
                v-if="ruleForm.customer_id == 18323"
              >
                <template slot="header">
                  <span style="color: red">*发货数量(CA)</span>
                </template>
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'goods.' + scope.$index + '.shipment_quantity'"
                    :rules="rules.shipment_quantity"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-input
                      v-model="scope.row.shipment_quantity"
                      oninput="value=value.replace(/[^0-9.]/g,'')"
                      :disabled="waybill_order_status"
                    ></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                property="goods_no"
                label="方案编码"
                prop="goods_no"
                width="180"
                v-if="is_incubator == false && ruleForm.customer_id != 18323"
              >
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'goods.' + scope.$index + '.goods_no'"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-input
                      v-model="scope.row.goods_no"
                      :disabled="waybill_order_status"
                    ></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                label="温层"
                width="180"
                key="10"
                v-if="is_incubator == false"
                prop="thermosphere"
                property="thermosphere"
              >
                <template slot="header">
                  <span style="color: red">*温层</span>
                </template>
                <template slot-scope="scope">
                  <el-form-item
                    class="form-thero"
                    style="margin-top: 16px"
                    :key="'goods.' + scope.$index + '.thermosphere'"
                    :prop="'goods.' + scope.$index + '.thermosphere'"
                    :rules="{
                      required: true,
                      message: '请选择温层',
                      trigger: 'blur',
                    }"
                  >
                    <el-select
                      id="goods_thermosphere_down"
                      v-model="scope.row.thermosphere"
                      placeholder="请选择"
                      :disabled="waybill_order_status"
                    >
                      <el-option
                        id="goods_thermosphere"
                        v-for="item in thermosphere"
                        :key="item.item_code"
                        :label="item.item_name"
                        :value="item.item_code"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                property="number"
                label="件数"
                prop="number"
                width="100"
                v-if="ruleForm.customer_id == 18323 || isZto"
                :disabled="waybill_order_status"
              >
                <template slot="header">
                  <span style="color: red">*件数</span>
                </template>
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'goods.' + scope.$index + '.number'"
                    :rules="rules.number"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-input
                      id="goods_number"
                      v-model.number="scope.row.number"
                      @change="accopNumber(2, scope)"
                      oninput="value=value.replace(/[^0-9]/g,'')"
                      :disabled="waybill_order_status"
                    ></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                property="number"
                label="件数"
                prop="number"
                width="100"
                v-else
              >
                <template slot="header">
                  <span>件数</span>
                </template>
                <template slot-scope="scope">
                  <el-input
                    id="goods_number"
                    v-model.number="scope.row.number"
                    @change="accopNumber(2, scope)"
                    oninput="value=value.replace(/[^0-9]/g,'')"
                    :disabled="waybill_order_status"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                property="weight"
                label="重量(kg)"
                prop="number"
                width="100"
                v-if="ruleForm.customer_id == 18323"
              >
                <template slot="header">
                  <span style="color: red">*重量(kg)</span>
                </template>
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'goods.' + scope.$index + '.weight'"
                    :rules="rules.weight"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-input
                      v-model="scope.row.weight"
                      @change="accopNumber(2, scope)"
                      oninput="value=value.replace(/[^0-9.]/g,'')"
                      :disabled="waybill_order_status"
                    ></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                property="weight"
                label="重量(kg)"
                prop="weight"
                width="100"
                v-else
              >
                <template slot="header">
                  <span>重量(kg)</span>
                </template>
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.weight"
                    @change="accopNumber(2, scope)"
                    oninput="value=value.replace(/[^0-9.]/g,'')"
                    :disabled="waybill_order_status"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                property="volume"
                label="体积(m³)"
                prop="volume"
                width="100"
                v-if="ruleForm.customer_id == 18323"
              >
                <template slot="header">
                  <span style="color: red">*体积(m³)</span>
                </template>
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'goods.' + scope.$index + '.volume'"
                    :rules="rules.volume"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-input
                      v-model="scope.row.volume"
                      @change="accopNumber(2, scope)"
                      oninput="value=value.replace(/[^0-9.]/g,'')"
                      :disabled="waybill_order_status"
                    ></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                property="volume"
                label="体积(m³)"
                prop="volume"
                width="100"
                v-else
              >
                <template slot="header">
                  <span>体积(m³)</span>
                </template>
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.volume"
                    @change="accopNumber(2, scope)"
                    oninput="value=value.replace(/[^0-9.]/g,'')"
                    :disabled="waybill_order_status"
                  ></el-input>
                </template>
              </el-table-column>

              <el-table-column
                property="packing"
                label="货物包装"
                width="120"
                key="11"
                v-if="is_incubator == true"
              >
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.packing"
                    clearable
                    placeholder=""
                    :disabled="waybill_order_status"
                  >
                    <el-option v-for="(value,key) in PackageData" :key="key" :label="value" :value="key">
                    </el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column
                property="packing"
                label="包装型号"
                width="180"
                key="12"
                v-else
              >
                <template slot-scope="scope">
                  <el-form-item
                    :rules="rules.package_type"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-select
                      id="goods_package_type_down"
                      v-model="scope.row.package_type"
                      placeholder="请选择"
                      @change="accopNumber(2, scope)"
                      :disabled="waybill_order_status"
                    >
                      <el-option
                        id="goods_package_type"
                        v-for="item in Package_model"
                        :key="item.item_code"
                        :label="item.item_name"
                        :value="item.item_code"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                property="packing"
                label="包装数量"
                prop="package_quantity"
                width="100"
                key="13"
              >
                <template slot-scope="scope">
                  <el-form-item
                    :rules="rules.package_quantity"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-input
                      id="goods_package_quantity"
                      v-model="scope.row.package_quantity"
                      placeholder="包装数量"
                      oninput="value=value.replace(/[^0-9]/g,'')"
                      @change="accopNumber(2, scope)"
                      :disabled="waybill_order_status"
                    ></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                property="frozen_box_number"
                label="冻存盒数量"
                prop="frozen_box_number"
                width="100"
                v-if="is_incubator == false"
              >
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'goods.' + scope.$index + '.frozen_box_number'"
                    style="margin-top: 16px"
                    label-width="0px"
                  >
                    <el-input
                      v-model="scope.row.frozen_box_number"
                      :disabled="waybill_order_status"
                    ></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                property="rule_cost_info"
                label="计费规则"
                width="180"
                key="14"
              >
                <template slot="header">
                  <span>计费规则</span>
                </template>
                <template slot-scope="scope">
                  <el-select
                    v-model="ruleForm.goods[scope.$index].rule_cost_info_id"
                    clearable
                    placeholder="请选择"
                    @change="
                      rulechange(
                        scope,
                        scope.row.rule_cost_info,
                        scope.row.rule_cost_info_id
                      )
                    "
                    :disabled="waybill_order_status"
                  >
                    <el-option
                      v-for="item in ruleForm.goods[scope.$index]
                        .rule_cost_info"
                      :key="item.rule_id"
                      :label="item.rule_name"
                      :value="item.rule_id"
                    >
                    </el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column
                property="price"
                label="价格(元)"
                width="100"
                key="6"
              >
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.price"
                    @input="
                      controlInputNumber(
                        scope.row.price,
                        2,
                        'ruleForm',
                        'goods',
                        scope.$index,
                        'price'
                      )
                    "
                    @change="AllShowprice()"
                    oninput="value=value.replace(/[^0-9.]/g,'')"
                    :disabled="waybill_order_status"
                  >
                  </el-input>
                </template>
              </el-table-column>
              <el-table-column
                property="declared_value"
                :label="isZto?'保价金额(元)':'价值(元)'"
                width="100"
                key="7"
              >
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.declared_value"
                    @input="
                      controlInputNumber(
                        scope.row.declared_value,
                        2,
                        'ruleForm',
                        'goods',
                        scope.$index,
                        'declared_value'
                      )
                    "
                    :disabled="waybill_order_status"
                  ></el-input>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <div
            style="
              height: 31px;
              width: 100%;
              background: #f2f3f5;
              text-align: right;
              line-height: 31px;
              margin: 10px 0px 10px 0px;
              font-size: 14px;
            "
          >
            <div style="padding-right: 10px">
              <span style="margin-right: 20px">发货合计:</span>
              <span
                style="margin-right: 20px"
                v-if="ruleForm.customer_id == 18323"
                >{{ deliverAll }}CA</span
              >
              <span style="margin-right: 20px">{{ NumberAll }}件</span>
              <span style="margin-right: 20px">{{ WeightAll }}kg</span>
              <span>{{ VloumerAll }}m³</span>
            </div>
          </div>
          <el-row>
            <el-col :span="12">
              <div class="order-shiper-img">
            <el-form-item label="随货同行单:" prop="uploadReceipt">
              <el-upload
                action
                :auto-upload="false"
                list-type="picture-card"
                :before-remove="beforeRemove"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :on-change="handleChange"
                :file-list="fileList"
              >
                <i class="el-icon-plus"></i>
              </el-upload>
              <!-- <el-dialog :visible.sync="dialogVisible">
                <img
                  width="100%"
                  :src="dialogImageUrl"
                  alt=""
                  style="max-height: 469px; object-fit: contain"
                />
              </el-dialog> -->
              <div class="images" v-viewer="{movable: false}" style="display: none">
                <img v-for="src in fileList" :src="src.url" :key="src.name">
              </div>
            </el-form-item>
              </div>
              <el-row>
            <el-col :span="6" v-if="isZto">
                <el-form-item label="货物类别" label-width="100px">
                  <el-select
                    v-model="ruleForm.zto_goods_category"
                    placeholder="请选择"
                    clearable
                  >
                    <el-option
                      v-for="(value,key) in GoodsTypeData"
                      :key="key"
                      :label="value"
                      :value="key"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
          </el-col>
          <el-col :span="6" v-if="isZto">
                <el-form-item label="物品类型" label-width="100px">
                  <el-select
                    v-model="ruleForm.zto_item_type"
                    placeholder="请选择"
                    clearable
                  >
                    <el-option
                      v-for="(value,key) in ItemTypeData"
                      :key="key"
                      :label="value"
                      :value="key"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
          </el-col>
              </el-row>
            </el-col>
            <el-col :span="12"                 v-if="!is_incubator">
              <el-table
                :data="ruleForm['settlement_package_info'] || []"
                style="width: 100%; margin-bottom: 20px"
                border
                center
              >
                  <el-table-column type="index" width="55"> </el-table-column>
                  <el-table-column label="实际结算包装型号" prop="settlement_package_type" width="200">
                    <template slot-scope="scope">
                      <el-form-item
                        label-width="0"
                        style="margin-top: 16px"
                        :prop="'settlement_package_info.' + scope.$index + '.settlement_package_type'"
                        :rules="rules.settlement_package_type"
                      >
                        <el-select
                            v-model="scope.row.settlement_package_type"
                            placeholder="请选择"
                            @change="pageaccountingrules(1, 'val')"
                        >
                            <el-option
                              v-for="item in Package_model"
                              :key="item.item_code"
                              :label="item.item_name"
                              :value="item.item_code"
                            >
                            </el-option>
                        </el-select>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="实际结算包装数量" prop="settlement_package_quantity"  width="200">
                    <template slot-scope="scope">
                      <el-form-item
                        label-width="0"
                        style="margin-top: 16px"
                        :prop="'settlement_package_info.' + scope.$index + '.settlement_package_quantity'"
                        :rules="rules.settlement_package_quantity"
                      >
                        <el-input
                            style="width:180px"
                            v-model="scope.row.settlement_package_quantity"
                            placeholder="请选择"
                            @input="pageaccountingrules(1, 'val')"
                        >
                        </el-input>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="操作" prop="">
                      <template slot-scope="scope">
                        <el-button type="text" @click="handleSettlementAdd()"
                          >添加</el-button
                        >
                        <el-button type="text" @click="handleSettlementDel(scope)"
                          >删除</el-button
                        >
                      </template>
                  </el-table-column>
              </el-table>
                <!-- <el-form-item
                    label="包装型号"
                    style="width:250px;display:inline-block"
                  >
                    <el-select
                      v-model="ruleForm"
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="item in Package_model"
                        :key="item.item_code"
                        :label="item.item_name"
                        :value="item.item_code"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item
                        label="包装数量"
                    style="width:250px;display:inline-block"

                  >
                    <el-input
                      v-model="ruleForm"
                      placeholder="请选择"
                    >
                    </el-input>
                  </el-form-item> -->
            </el-col>
          </el-row>
        </div>
        <!-- 运单信息 -->
        <div class="order-inter" v-if="ruleForm.customer_id == 18323">
          <div class="order-shiper-header">
            <span>百特装运单信息</span>
          </div>
          <div class="order-inter-message" style="padding-right: 20px">
            <el-row>
              <el-col :span="8">
                <el-form-item label="供货企业" label-width="130px">
                  <el-input
                    v-model="bt_extra.supply_company"
                    placeholder="请输入供货企业/药品上市许可持有人"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="生产企业" label-width="130px">
                  <el-input v-model="bt_extra.manufacturer_company"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="客户运单号" label-width="130px">
                  <el-input v-model="bt_extra.customer_order_no"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="5">
                <el-form-item
                  label="买方公司"
                  label-width="130px"
                  style="margin-right: 4px"
                >
                  <el-input
                    v-model="bt_extra.purchaser_id"
                    placeholder="请输入ID"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="3">
                <div>
                  <el-input
                    v-model="bt_extra.purchaser_name"
                    placeholder="请输入买方公司名称"
                    style="width: 100%"
                  ></el-input>
                </div>
              </el-col>
              <el-col :span="8">
                <el-form-item label="买方详细地址" label-width="130px">
                  <el-input
                    v-model="bt_extra.purchaser_address"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="发往ID" label-width="130px">
                  <el-input
                    v-model="bt_extra.send_to_id"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item
                  label="运输商"
                  label-width="130px"
                  style="margin-right: 4px"
                >
                  <el-input
                    v-model="bt_extra.carrier_id"
                    placeholder="请输入ID"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="3">
                <div>
                  <el-input
                    v-model="bt_extra.carrier_name"
                    placeholder="请输入承运商"
                  ></el-input>
                </div>
              </el-col>
              <el-col :span="5">
                <el-form-item
                  label="运输方式"
                  label-width="130px"
                  style="margin-right: 4px"
                >
                  <el-input
                    v-model="bt_extra.shipment_mode_id"
                    placeholder="请输入ID"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="3">
                <div>
                  <el-input
                    v-model="bt_extra.shipment_mode_name"
                    placeholder="请输入运输方式"
                  ></el-input>
                </div>
              </el-col>
              <el-col :span="5">
                <el-form-item
                  label="Branch/Plant"
                  label-width="130px"
                  style="margin-right: 4px"
                >
                  <el-input
                    v-model="bt_extra.branch_plant_id"
                    placeholder="请输入ID"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="3">
                <div>
                  <el-input
                    v-model="bt_extra.branch_plant_name"
                    placeholder="请输入Branch/Plant"
                  ></el-input>
                </div>
              </el-col>
              <el-col :span="8">
                <el-form-item label="Shipment No." label-width="130px">
                  <el-input
                    v-model="bt_extra.shipment_no"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="Container ID" label-width="130px">
                  <el-input
                    v-model="bt_extra.container_id"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="集装箱/集装箱数" label-width="130px">
                  <el-input
                    v-model="bt_extra.container_number"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="集装箱封号" label-width="130px">
                  <el-input
                    v-model="bt_extra.container_no"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="附检验报告份数" label-width="130px">
                  <el-input
                    v-model="bt_extra.report_count"
                    style="width: 100%"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </div>
        <!-- 合计运费 -->
        <div class="order-freight">
          <div class="order-shiper-header">
            <span>合计运费:</span>
            <span>{{ alltotal_cost | afterTime }} 元</span>
            <span style="display:inline-block;font-size: 11px;margin-left: 30px;" v-if="advicePrice">建议运费：{{ advicePrice }}元</span>
          </div>
          <div class="order-inter-message">
            <div class="order-inter-message_right">
              <el-row>
                <el-col :span="6">
                  <el-form-item label="运费">
                    <el-input
                      :disabled="ruleForm.pay_status !== '0'"
                      id="freight_fee"
                      v-model="ruleForm.expense[1]"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="保价费">
                    <el-input
                      :disabled="ruleForm.pay_status !== '0'"
                      v-model="ruleForm.expense[8]"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="提货费">
                    <el-input
                      :disabled="ruleForm.pay_status !== '0'"
                      v-model="ruleForm.expense[5]"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="装卸费">
                    <el-input
                      :disabled="ruleForm.pay_status !== '0'"
                      v-model="ruleForm.expense[6]"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="6">
                  <el-form-item label="包装费">
                    <el-input
                      :disabled="ruleForm.pay_status !== '0'"
                      v-model="ruleForm.expense[9]"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="送货费">
                    <el-input
                      :disabled="ruleForm.pay_status !== '0'"
                      v-model="ruleForm.expense[4]"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="其他费用">
                    <el-input
                      :disabled="ruleForm.pay_status !== '0'"
                      v-model="ruleForm.expense[10]"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
            <div class="order-inter-message_left">
              <el-row>
                <el-form-item label="付款方式">
                  <div style="display: flex">
                    <el-select
                      style="width: 80px; margin-right: 15px"
                      :disabled="ruleForm.pay_status !== '0'"
                      id="pay_methods_down"
                      v-model="ruleForm.payment_id"
                      placeholder="请选择"
                    >
                      <el-option
                        id="pay_methods"
                        v-for="item in pay_way"
                        :key="item.item_code"
                        :label="item.item_name"
                        :value="item.item_code"
                      >
                      </el-option>
                    </el-select>
                    <div>{{ alltotal_cost }} 元</div>
                  </div>
                </el-form-item>
              </el-row>
              <el-row>
                <el-form-item label="支付状态">
                  {{
                    // ruleForm.pay_status === "0"
                    //   ? "未支付"
                    //   : ruleForm.pay_status === "1"
                    //   ? "已支付"
                    //   : ruleForm.pay_status === "2"
                    //   ? "已退款"
                    //   : ""
                    PAY_STATUS[ruleForm.pay_status]
                  }}
                </el-form-item>
              </el-row>
            </div>
          </div>
        </div>
        <!-- 增值服务 -->
        <div class="order-appreciation">
          <div class="order-shiper-header">
            <span>其他信息</span>
          </div>
          <div
            style="padding: 10px 0px 0px 0px; border-bottom: 1px solid #ecb17a"
          >
            <el-row>
              <el-col :span="6">
                <el-form-item label="出发网点">
                  <el-cascader
                    style="width: 150px"
                    v-model="ruleForm.from_network_id"
                    :options="originList"
                    :props="propsBranchType"
                    :show-all-levels="false"
                    clearable
                    filterable
                    :disabled="
                      (required_setting_list[0]
                        ? required_setting_list[0].item_value === '0'
                        : true) || waybill_order_status == true
                    "
                  >
                  </el-cascader>
                  <el-tooltip
                    v-if="
                      required_setting_list[0]
                        ? required_setting_list[0].item_value === '0'
                        : true
                    "
                    class="item"
                    effect="dark"
                    content="出发网点、目的网点根据发货城市、收货城市自动匹配，如需修改请修改组织架构-组织-分管城市"
                    placement="bottom"
                  >
                    <i
                      style="
                        position: absolute;
                        color: darkorange;
                        font-size: 18px;
                        margin-top: 3px;
                        margin-left: 2px;
                      "
                      class="el-icon-info"
                    ></i>
                  </el-tooltip>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="目的网点">
                  <el-cascader
                    style="width: 150px"
                    v-model="ruleForm.to_network_id"
                    :options="originList"
                    :props="propsBranchType"
                    :show-all-levels="false"
                    clearable
                    filterable
                    :disabled="
                      (required_setting_list[0]
                        ? required_setting_list[0].item_value === '0'
                        : true) || waybill_order_status == true
                    "
                  >
                  </el-cascader>
                  <el-tooltip
                    v-if="
                      required_setting_list[0]
                        ? required_setting_list[0].item_value === '0'
                        : true
                    "
                    class="item"
                    effect="dark"
                    content="出发网点、目的网点根据发货城市、收货城市自动匹配，如需修改请修改组织架构-组织-分管城市"
                    placement="bottom"
                  >
                    <i
                      style="
                        position: absolute;
                        color: darkorange;
                        font-size: 18px;
                        margin-top: 3px;
                        margin-left: 2px;
                      "
                      class="el-icon-info"
                    ></i>
                  </el-tooltip>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="发站">
                  <el-input
                    style="width: 150px"
                    v-model="ruleForm.from_region"
                    :disabled="waybill_order_status"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="到站">
                  <el-input
                    style="width: 150px"
                    v-model="ruleForm.to_region"
                    :disabled="waybill_order_status"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item label="路由">
                  <el-select
                    v-model="ruleForm.router"
                    allow-create
                    filterable
                    remote
                    reserve-keyword
                    @change="nounrouter"
                    :remote-method="Pageroutername"
                    style="width: 150px"
                    :disabled="waybill_order_status"
                  >
                    <el-option
                      v-for="item in routerboxList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="预计签收时间">
                  <span
                    style="color: #606266"
                    v-time="ruleForm.expected_signing_time"
                  ></span>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="经办人">
                  <span style="color: #606266">{{ nickname }}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="order-inter-message">
            <el-row>
              <el-col :span="6">
                <el-form-item label="送货方式" label-width="100px">
                  <el-select
                    v-if="isZto"
                    style="width: 150px"
                    v-model="ruleForm.zto_delivery_type"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="(value,key) in DeliveryTypeData"
                      :key="key"
                      :label="value"
                      :value="key"
                    >
                    </el-option>
                  </el-select>
                  <el-select
                    v-else
                    id="delivery_method_down"
                    style="width: 150px"
                    v-model="ruleForm.delivery_method"
                    placeholder="请选择"
                  >
                    <el-option
                      id="delivery_method"
                      v-for="item in delivery_method"
                      :key="item.item_code"
                      :label="item.item_name"
                      :value="item.item_code"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="紧急度" label-width="100px">
                  <el-select
                    style="width: 150px"
                    v-model="ruleForm.priority_level"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="item in order_priority_level"
                      :key="item.item_code"
                      :label="item.item_name"
                      :value="item.item_code"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" label-width="100px">
                <el-form-item label="回单">
                  <el-checkbox v-model="ruleForm.is_receipt_customer"
                    >客户回单</el-checkbox
                  >
                  <el-checkbox v-model="ruleForm.is_receipt_ds"
                    >我司回单</el-checkbox
                  >
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="isZto && (ruleForm.is_receipt_customer||ruleForm.is_receipt_ds)">
                <el-form-item label="回单类型" label-width="100px">
                  <el-select
                    v-model="ruleForm.zto_receipt_type"
                    clearable
                    placeholder=""
                  >
                    <el-option v-for="(value,key) in ReceiptTypeData" :key="key" :label="value" :value="key">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="运单备注">
                  <el-input
                    id="waybill_remark"
                    style="width: 150px"
                    v-model="ruleForm.remark"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="代收货款" label-width="100px">
                  <el-input
                    v-model="ruleForm.agent_collection.service_charge"
                    style="width: 150px"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </div>
      </el-form>
    </div>
  </div>
</template>
  <script>
import {
  WaybillAddFn,
  dictionaryBatch,
  getTransportsList,
  reqHandlersList,
  getConsignorList,
  ConsigneeInterface,
  reqWebsiteList,
  regionbox,
  getRegionList,
  getRouterList,
  recognitionListcity,
  accountingrules, //计费规则接口
  routerbox,
  WaybillEditFn,
  WaybillDetailFn,
  CollectTimeControl,
  WaybillWxPayQrcode,
  reqRefund,
  WaybillPaymentStatus,
  waybill_order_edit_status, //揽收完成后运单编辑权限限制
  distributionBatchList, //通过运单调用获取配送单的id
  DistributionDeleteFn, //配送
  customer_order_params, //获取订单默认配置的接口
} from "@/api/waybill";
import {
  PagewebsiteList,
  regionList,
  dictionanryList,
  uploading,
} from "../../page/material/common/common";
import { organizationBox } from "@/api/organization";
import {
  timestamp10,
  filterTwoNumber,
  filterThreeNumber,
} from "@/utils/mUtils"; // 时间转化
import { order_details, addstate, updateorder_details } from "@/api/orderForm";
import { reqRequiredField } from "@/api/print";
import { customerPeople } from "@/api/information";
import BackMoney from "@/components/backMoney/index.vue";
import SelectAddress from "@/components/selectAddress/index.vue";
import notify from "@/components/notify/notify.vue"; // 时间转化
import { PAY_STATUS, PackageData, ReceiptTypeData, DeliveryTypeData,GoodsTypeData,ItemTypeData} from "@/utils/constants";

export default {
  props: ["id", "wayType", "Typeinformation"],
  components: {
    BackMoney,
    SelectAddress,
    notify,
  },
  data() {
    return {
      toPaymentLoading: false,
      addLoading: false,
      updateLoading: false,
      paymentQrcodeVisible: false, //微信支付二维码
      qrcodeUrl: "",
      showPaymentBtn: false, //揽收完成才显示
      refundVisible: false, //退款的弹出框
      refundConfirmVisible: false, //退款二次确认的
      // localtype用户
      localStorage_id: JSON.parse(localStorage.getItem("user")).type,
      // 创建人
      nickname: JSON.parse(localStorage.getItem("user")).nickname,
      // 所属客户
      clientList: [],
      //发货公司名字
      sender_company_name: "",
      sender_company_id: "",
      // 将运费的部分禁用掉
      disabled_type: true,
      // 判断是否是保温箱页面
      is_incubator: true,
      // 上传内容
      fileList: [], //上传的文件
      dialogImageUrl: "",
      dialogVisible: false,
      activeName: 0,
      disabled_value: false,
      allorderType: "",
      // alltotal_cost: 0,//总运费
      Pay_name: "月结", //付款名称
      ruleForm: {
        handler_id: JSON.parse(localStorage.getItem("user")).user_id, //当前创建人的id
        handler_name: "", //当前创建人的名字
        customer_id: "", //所属客户
        is_view_freight: "0", //
        waybill_number: "", //运单号
        remark: "", //运单备注
        insure_value: 0, //是否投保 0 不投保 1 投保
        waybill_product_type: "", //承运类型id
        valid_time: "", //时效
        addressList: [], //发货地址
        receiverList: [], //收货地址
        // 发货人
        sender: {
          id: "",
          name: "", //发货人名字
          phone: "", //手机号
          address: "", //详细地址
          company: "", //发货公司
          customer_id: "", //发货公司id
          province_id: "",
          city_id: "",
          district_id: "",
          province_name: "",
          city_name: "",
          district_name: "",
        },
        // 收货人
        receiver: {
          id: "",
          name: "",
          phone: "",
          company: "",
          customer_id: "",
          address: "",
          province_id: "",
          city_id: "",
          district_id: "",
          province_name: "",
          city_name: "",
          district_name: "",
        },
        // 提货时间
        collect_time: {
          start_time: "",
          end_time: "",
        },
        // 货物信息
        goods: [
          {
            name: "", //产品名称
            packing: "", //货物包装
            goods_no: "", //产品编号
            number: "", //件数
            weight: "", //重量
            volume: "", //体积
            price: "", //价格
            declared_value: "", //价值
            specification: "", //规格
            commodity_model: "", //模型
            package_type: "", //包装型号
            thermosphere: "",
            product_batch: "", //产品批次号
            product_valid_period: "", //产品有效期
            shipment_quantity: "", //发货数量
            package_quantity: "1", //包装数量
          },
        ],
        //
        expense: {
          // 运费 提货费 送货费 包装费 手续费 保价费 报价金额 代收货款
          1: "0", //运费
          2: "0",
          3: "0",
          4: "0", //送货费
          5: "0", //提货费
          6: "0",
          7: "0",
          8: "0", //保价费
          9: "0", //包装费
          10: "0", //其他费用
          11: "0", //代收货款
          12: "0", //手续费
          total_freight: "",
        },
        // 运单类型
        type: "",
        // 始发网点
        from_network_id: [],
        from_network: "",
        // 目的网点
        to_network_id: [],
        to_network: "",
        // 发站id
        from_region_id: "",
        // 发站名字
        from_region: "",
        // 到站id
        to_region_id: "",
        to_region: "",
        // 路由id
        router_id: "",
        router: "",
        // 温度
        thermosphere: "",
        // 湿度
        humidity: "0",
        // 运输方式
        transport_way: "0",
        // 送货方式
        delivery_method: "",
        // 紧急程度
        priority_level: "0",
        // 付款方式
        payment_id: "4",
        // 回单数
        receipt_count: "1", //0是没用回单1是回单
        // 图片
        images: [],
        is_receipt_customer: true,
        is_receipt_ds: true,
        status: "",
        pay_status: "0", //0未支付,1已支付,2已退款
        expected_signing_time: "", //预计签收时间
        // 提货时间
        value1: new Date().getTime(),
        // 中通新增回单类型
        zto_receipt_type: '',
        // 中通新增送货方式
        zto_delivery_type: '0',
        // 中通新增物品类别
        zto_item_type: '5',
        // 中通新增货物类型
        zto_goods_category: '0',
        agent_collection:{
          service_charge:''
        },
        settlement_package_info:[{
        settlement_package_type:"", // 实际结算包装类型
        settlement_package_quantity:"" // 实际结算包装数量
         }] 

      },
      rules: {
        // 所属客户
        customer_id: [{ required: true, message: "所属客户", trigger: "blur" }],
        // "collect_time.start_time": [
        //   { required: false, message: "请选择提货时间", trigger: "blur" },
        // ],
        // 发货方
        "sender.name": [
          { required: true, message: "请输入发货人", trigger: "blur" },
        ],
        "sender.phone": [
          { required: true, message: "请输入发货人手机号", trigger: "blur" },
        ],

        "sender.address": [
          { required: true, message: "请输入发货人详细地址", trigger: "blur" },
        ],
        addressList: [
          {
            required: true,
            message: "请输入发货人省市区地址",
            trigger: "blur",
          },
        ],
        "sender.company": [
          { required: true, message: "请输入发货公司", trigger: "blur" },
        ],
        // 收货人
        "receiver.name": [
          { required: true, message: "请输入收货人", trigger: "blur" },
        ],
        "receiver.phone": [
          { required: true, message: "请输入收货人电话", trigger: "blur" },
        ],
        "receiver.address": [
          { required: true, message: "请输入收货人详细地址", trigger: "blur" },
        ],
        receiverList: [
          {
            required: true,
            message: "请输入收货人省市区地址",
            trigger: "blur",
          },
        ],
        "receiver.company": [
          { required: true, message: "请输入收货公司", trigger: "blur" },
        ],
        name: [{ required: true, message: "请输入货物名称", trigger: "blur" }],
        waybill_product_type: [
          { required: true, message: "请选择承运类型", trigger: "blur" },
        ],
        thermosphere: [
          { required: true, message: "请选择温层", trigger: "blur" },
        ],
        goods_no: [
          { required: true, message: "请输入产品编码", trigger: "blur" },
        ],
        shipment_quantity: [
          { required: true, message: "请输入发货数量", trigger: "blur" },
        ],
        number: [
          { required: true, message: "请输入发货件数", trigger: "blur" },
        ],
        weight: [{ required: true, message: "请输入重量", trigger: "blur" }],
        volume: [{ required: true, message: "请输入体积", trigger: "blur" }],
        value1: [
          { required: false, message: "请选择时间", trigger: "blur" },
        ],
      },
      // 发货人
      consignorList: [],
      // 收货人列表
      ConsigneeInterfaceList: [],
      // 地址库
      addresssequence: [],
      originList: [], //组织
      // 发站
      // regionboxList: [],
      // 路由
      routerboxList: [],
      // 运单类型
      order_type: [],
      // 温度
      thermosphere: [],
      // 湿度
      humidity: [],
      // 送货方式
      delivery_method: [],
      // 紧急程度
      order_priority_level: [],
      // 运输方式
      transport_way_List: [],
      // 付款方式
      pay_way: [],
      //费用
      cost: [],
      // 保温箱型号
      Package_model: [],

      carrier_type: [], //承运类型列表
      propsBranchType: {
        emitPath: true,
        checkStrictly: true,
        value: "id",
        label: "branch_name",
        children: "next_level_data",
      },
      originListData: [],
      create_time: new Date(), //创建时间
      bt_extra: {
        supply_company: "",
        manufacturer_company: "",
        customer_order_no: "",
        shipment_mode_id: "",
        shipment_mode_name: "",
        shipment_no: "",
        branch_plant_id: "",
        branch_plant_name: "",
        carrier_id: "",
        carrier_name: "",
        container_id: "",
        container_number: "",
        container_no: "",
        purchaser_id: "",
        purchaser_name: "",
        purchaser_address: "",
        send_to_id: "",
        report_count: "",
      },
      deliverAll: 0,
      NumberAll: 0,
      WeightAll: "0.000",
      VloumerAll: "0.000",
      required_setting_list: [],
      refundValue: {
        //退款信息
        waybill_id: "",
        refund_time: "",
        remark: "",
      },
      createTime: Date.now(),
      timer: {},
      paySuccess: false,
      keyType: 1, //当页面太多的时候刷新页面
      waybill_order_status: false, //揽收完成不可编辑的信息
      setting_list_type: true,
      backDialogVisible: false, //申请退款弹框
      PAY_STATUS: PAY_STATUS,
      addressDialogVisible: false, // 选择地址弹框
      clickFrom: "", // sender-发件人详细地址 receiver-收件人
      collectionTime: "", //揽收时间
      goodThermosphere: "", //货物温层
      notifyType: false,
      noTifyData: {
        customer_id: "",
        product_type_id: "",
        node_id: "",
      },
      PackageData:PackageData,
      ReceiptTypeData:ReceiptTypeData,
      DeliveryTypeData:DeliveryTypeData,
      GoodsTypeData:GoodsTypeData,
      ItemTypeData:ItemTypeData,
      advicePrice:''
    };
  },
  computed: {
    // 计算属性的 getter
    alltotal_cost: function () {
      var totalMony =
        Number(this.ruleForm.expense[1]) +
        Number(this.ruleForm.expense[8]) +
        Number(this.ruleForm.expense[5]) +
        Number(this.ruleForm.expense[6]) +
        Number(this.ruleForm.expense[9]) +
        Number(this.ruleForm.expense[4]) +
        Number(this.ruleForm.expense[10]);
      return totalMony.toFixed(2);
    },
    isZto: function(){
      return this.ruleForm.waybill_product_type==="43"
    }
  },
  watch: {
    // 监听承运类型用来匹配计费规则
    "ruleForm.waybill_product_type": "watchwaybill",
    // 监听所属客户用来匹配计费规则
    "ruleForm.customer_id": "watchcustomer",
    // 监听货物的改变
    "ruleForm.goods": {
      handler(newval, oldval) {
        var D = 0;
        var N = 0;
        var W = 0;
        var V = 0;
        this.ruleForm.goods.forEach((item) => {
          D += item.shipment_quantity * 1;
          N += item.number * 1;
          W += item.weight * 1;
          V += item.volume * 1;
        });
        this.deliverAll = D.toFixed();
        this.NumberAll = N.toFixed();
        this.WeightAll = W.toFixed(3);
        this.VloumerAll = V.toFixed(3);
        // this.$forceUpdate();
      },
      loading: true,
      deep: true,
      flush: "post",
    },
    //  监听发货地址
    "ruleForm.addressList": {
      handler(newval, oldval) {
        this.pageaccountingrules(1, "val");
      },
      deep: true,
    },
    "ruleForm.receiverList": {
      handler(newval, oldval) {
        this.pageaccountingrules(1, "val");
      },
      deep: true,
    },
  },
  filters: {
    afterTime(value) {
      if (isNaN(value)) {
        return "请输入正确的金钱格式(1或0.1)";
      } else {
        return value;
      }
    },
  },
  methods: {
    handleSettlementAdd(){
      this.ruleForm.settlement_package_info.push(
        {
        "settlement_package_type":"", // 实际结算包装类型
        "settlement_package_quantity":""  // 实际结算包装数量
        }
      )
    },
    handleSettlementDel(scope){
      if(this.ruleForm.settlement_package_info.length===1){
           this.$message({
                message: "最后一条暂不可删除",
                type: "warning",
          });
        return;
      }
      this.ruleForm.settlement_package_info.splice(scope.$index,1)
    },
    handleChangeStartTime(val) {
      // this.ruleForm.collect_time = {
      //   start_time: timestamp10(this.value1),
      //   end_time: "",
      // };
      // console.log(val,"fjalksdfjlldfjasld")
      // if (val == null) {
      //     this.ruleForm.value1 = ""
      //     this.ruleForm.collect_time = {
      //       start_time: timestamp10(this.ruleForm.value1),
      //       end_time: "",
      //     };
      //   } else {
      //     this.ruleForm.value1 = this.ruleForm.value1 + this.collectionTime * 3600000
      //     this.ruleForm.collect_time = {
      //       start_time: timestamp10(this.ruleForm.value1),
      //       end_time: "",
      //     };
      //   }
      this.ruleForm.collect_time = {
        start_time: timestamp10(this.ruleForm.value1),
        end_time: "",
      };
    },
    handleReturnMoney() {
      this.backDialogVisible = true;
    },
    handleCloseBackDialog(isUpdated) {
      this.backDialogVisible = false;
      if (isUpdated) {
        this.Pageorder_details();
      }
    },
    handleShowAddressDialog(origin) {
      if (this.disabled_value || this.waybill_order_status) {
        return;
      }
      this.clickFrom = origin;
      this.addressDialogVisible = true;
    },
    handleCloseAddressDialog() {
      this.addressDialogVisible = false;
    },
    handleAddressDialogOk(data) {
      console.log(data, "data select address");
      if (this.clickFrom == "sender") {
        this.ruleForm.sender.address = data.address;
        this.ruleForm.begin_longitude = data.lon;
        this.ruleForm.begin_latitude = data.lat;
        this.FuzhiChange();
      } else if (this.clickFrom == "receiver") {
        this.ruleForm.receiver.address = data.address;
        this.ruleForm.end_longitude = data.lon;
        this.ruleForm.end_latitude = data.lat;
        this.FuzhiReceiverChange();
      }
    },
    async getHandlersList() {
      let result = await reqHandlersList({ branch_id: "1" });
      if (result.data != undefined) {
        this.ruleForm.handler_name = result.data.find(
          (item) => item.id == this.ruleForm.handler_id
        ).nickname;
      }
    },
    searchCustomerList(query) {
      //获取客户
      if (query !== "") {
        setTimeout(async () => {
          let result = await customerPeople({
            name: query, // 名称
            id: "",
            is_send: "1",
            is_receive: "",
          });
          if (result.data.length > 0) {
            this.clientList = result.data;
          } else {
            this.clientList = [];
          }
        }, 200);
      } else {
        this.clientList = [];
      }
    },
    selectedCustomer(id) {
      this.notifyType = false;
      //选择客户
      this.ruleForm.customer_id = this.clientList.find(
        (item) => item.id == id
      ).id;
      this.ruleForm.valid_time = this.clientList.find(
        (item) => item.id == id
      ).valid_time;
      let product_type_name = this.clientList.find(
        (item) => item.id == id
      ).product_type_id;
      let product_type_id_id = this.clientList.find(
        (item) => item.id == id
      ).product_type_id;
      this.ruleForm.payment_id =
        this.clientList.find((item) => item.id == id).payment + "";
      var param = {
        id: id,
      };
      customer_order_params(param).then((res) => {
        if (res.code == 10000) {
          this.ruleForm.insure_value = res.data.IsInsure;
          this.ruleForm.priority_level = res.data.PriorityLevel + "";
          this.ruleForm.delivery_method = res.data.DeliveryMethod + "";
          this.ruleForm.is_receipt_customer =
            res.data.IsReceiptCustomer > 0 ? true : false;
          this.ruleForm.is_receipt_ds = res.data.IsReceiptDs > 0 ? true : false;
          if (this.ruleForm.type == 2) {
            this.goodThermosphere = "";
            this.ruleForm.thermosphere = res.data.Thermosphere + "";
          } else if (this.ruleForm.type == 1) {
            this.goodThermosphere = res.data.Thermosphere + "";
            this.ruleForm.goods[0].thermosphere = res.data.Thermosphere + "";
          } else {
            this.goodThermosphere = "";
          }
          this.collectionTime = res.data.CollectTime;
          // 将提货时间清空
          // this.ruleForm.value1 = ""
          this.ruleForm.value1 =
            new Date().getTime() + this.collectionTime * 3600000;
          this.handleChangeStartTime();
        }
      });
      this.selectTransportsType(product_type_id_id, "2");
      this.ruleForm.waybill_product_type =
        product_type_name == 0 ? "" : product_type_name + "";
      this.ruleForm.is_view_freight = this.clientList.find(
        (item) => item.id == id
      ).is_view_freight;
      this.bt_extra = {
        supply_company: "",
        manufacturer_company: "",
        customer_order_no: "",
        shipment_mode_id: "",
        shipment_mode_name: "",
        shipment_no: "",
        branch_plant_id: "",
        branch_plant_name: "",
        carrier_id: "",
        carrier_name: "",
        container_id: "",
        container_number: "",
        container_no: "",
        purchaser_id: "",
        purchaser_name: "",
        purchaser_address: "",
        send_to_id: "",
        report_count: "",
      };
      if (this.ruleForm.customer_id == 18323) {
        this.keyType = 3;
      } else {
        this.keyType = 4;
      }
      this.NotificationObj();
    },
    // 用户
    locationcustore() {
      if (this.localStorage_id == 1) {
        setTimeout(async () => {
          let result = await customerPeople({
            name: "", // 名称
          });
          if (result.data.length > 0) {
            this.clientList = result.data;
            this.ruleForm.customer_id = result.data[0].id;
          } else {
            this.clientList = [];
          }
        }, 200);
      }
    },
    // 所属客户
    searchCustomerid(id) {
      setTimeout(async () => {
        let result = await customerPeople({
          name: "", // 名称
          id: id,
          is_send: "",
          is_receive: "",
        });
        if (result.data.length > 0) {
          this.clientList = result.data;
        } else {
          this.clientList = [];
        }
      }, 200);
    },
    // 发 货地址来自动渲染发站
    shiphandleChange() {
      this.ruleForm.sender.province_name = "";
      this.ruleForm.sender.city_name = "";
      this.ruleForm.sender.district_name = "";
      var detailed = {
        province_id: this.ruleForm.addressList[0],
        city_id: this.ruleForm.addressList[1],
        type: 1,
      };
      this.addressData(detailed);
    },
    // 收货地址累自动渲染到站
    rechandleChange() {
      this.ruleForm.receiver.province_name = "";
      this.ruleForm.receiver.city_name = "";
      this.ruleForm.receiver.district_name = "";
      var detailed = {
        province_id: this.ruleForm.receiverList[0],
        city_id: this.ruleForm.receiverList[1],
        type: 2,
      };
      this.addressData(detailed);
    },
    // 处理数据
    addressData(value) {
      if (value.type == 1) {
        var fireaddress = this.addresssequence.find(
          (res) => res.id == value.province_id
        );
        var fireaddresschild = fireaddress.next_level_data;
        var seconddress = fireaddresschild.find(
          (res) => res.id == value.city_id
        );
        if (seconddress.name == undefined) {
          this.ruleForm.from_region = "";
        } else {
          this.ruleForm.from_region = seconddress.name;
        }
      } else if (value.type == 2) {
        var fireaddress = this.addresssequence.find(
          (res) => res.id == value.province_id
        );
        var fireaddresschild = fireaddress.next_level_data;
        var seconddress = fireaddresschild.find(
          (res) => res.id == value.city_id
        );
        if (seconddress.name == undefined) {
          this.ruleForm.to_region = "";
        } else {
          this.ruleForm.to_region = seconddress.name;
        }
      }
    },
    //根据详细地址获取省市区 发货信息
    FuzhiChange() {
      let data = {
        detail_address: this.ruleForm.sender.address,
      };
      recognitionListcity(data).then((res) => {
        if (
          res.data.province_name !== "暂无省信息" &&
          res.data.city_name !== "暂无市信息" &&
          res.data.area_name !== "暂无区信息"
        ) {
          this.ruleForm.addressList = [
            res.data.province_id,
            res.data.city_id,
            res.data.area_id,
          ];
          this.ruleForm.sender.province_name = res.data.province_name;
          this.ruleForm.sender.city_name = res.data.city_name;
          this.ruleForm.sender.district_name = res.data.area_name;
          var detailed = {
            province_id: res.data.province_id,
            city_id: res.data.city_id,
            type: 1,
          };
          this.addressData(detailed);
        }
      });
    },
    //根据详细地址获取省市区 收货信息
    FuzhiReceiverChange() {
      let data = {
        detail_address: this.ruleForm.receiver.address,
      };
      recognitionListcity(data).then((res) => {
        if (
          res.data.province_name !== "暂无省信息" &&
          res.data.city_name !== "暂无市信息" &&
          res.data.area_name !== "暂无区信息"
        ) {
          this.ruleForm.receiverList = [
            res.data.province_id,
            res.data.city_id,
            res.data.area_id,
          ];
          this.ruleForm.receiver.province_name = res.data.province_name;
          this.ruleForm.receiver.city_name = res.data.city_name;
          this.ruleForm.receiver.district_name = res.data.area_name;
          var detailed = {
            province_id: res.data.province_id,
            city_id: res.data.city_id,
            type: 2,
          };
          this.addressData(detailed);
        }
      });
    },
    selectTransportsType(val, type) {
      this.notifyType = false;
      console.log(this.carrier_type,'this.carrier_type')
      var is_insure_value = this.carrier_type.find((item) => item.id == val);
      //选择承运产品类型之后 通过承运类型选择温层是否展示
      if (is_insure_value == undefined) {
        this.is_incubator = true;
        this.ruleForm.type = "";
        this.keyType = 2;
      } else {
        if (is_insure_value.is_incubator == "1") {
          this.is_incubator = false;
          this.ruleForm.type = "1";
          this.keyType = 1;
        } else {
          this.is_incubator = true;
          if (is_insure_value.is_incubator == "0") {
            this.ruleForm.type = "0";
            this.ruleForm.thermosphere = "8";
          } else if (is_insure_value.is_incubator == "2" && type != 2) {
            this.ruleForm.type = "2";
            this.ruleForm.thermosphere = "";
          } else if (is_insure_value.is_incubator == "2" && type == 2) {
            this.ruleForm.type = "2";
          }
          this.keyType = 2;
        }
      }
      this.NotificationObj();
    },
    async pagegetTransportsList() {
      let param = {
        is_all: false,
      };
      // getTransportsList(param).then((res) => {
      //   var res = res.data;
      //   this.carrier_type = res.data;
      // });
      const res=await getTransportsList(param);
      const data=res.data||{}
      this.carrier_type = data.data||[];
    },
    // 发货人选中的数据
    sender_selected_data(event) {
      var receiver_value = event.target.value;
      let receiver_name = this.ConsigneeInterfaceList.find(
        (item) => item.name == receiver_value
      );
      if (receiver_name == undefined) {
        this.ruleForm.sender.company_id = "";
      } else {
        this.ruleForm.sender.company_id = this.ruleForm.sender.company_id;
      }
    },
    // 如果发现没有发货人清空id和发货公司id
    sender_customer_id() {
      var sender_name = this.ruleForm.sender.name;
      let piece_value = this.consignorList.find(
        (item) => item.name == sender_name
      );
      if (piece_value == undefined) {
        this.ruleForm.sender.customer_id = "";
        this.ruleForm.sender.id = "";
      } else {
      }
    },
    receiver_customer_id() {
      var receiver_name = this.ruleForm.receiver.name;
      let piece_value = this.ConsigneeInterfaceList.find(
        (item) => item.name == receiver_name
      );
      if (piece_value == undefined) {
        this.ruleForm.receiver.customer_id = "";
        this.ruleForm.receiver.id = "";
      } else {
      }
    },
    // 收货人选中的数据
    receiver_selected_data(event) {
      var receiver_value = event.target.value;
      let receiver_name = this.ConsigneeInterfaceList.find(
        (item) => item.name == receiver_value
      );
      if (receiver_name == undefined) {
        this.ruleForm.receiver.company_id = "";
      } else {
        this.ruleForm.receiver.company_id = this.ruleForm.receiver.company_id;
      }
    },
    // 数据字典
    pagedictionanryList() {
      // thermosphere 温度 humidity 湿度 delivery_method 送货方式 order_priority_level 紧急度
      // transport_way 运输方式 pay_way 付款方式  order_type 运单类型 cost 费用 Package_model 包装
      var param = [
        "order_type",
        "thermosphere",
        "humidity",
        "delivery_method",
        "order_priority_level",
        "transport_way",
        "pay_way",
        "Package_model",
      ];
      dictionanryList(param).then((res) => {
        var res = res.data.list;
        var payList = [];
        res.pay_way.forEach((element) => {
          if (element.item_code != "0") {
            payList.push(element);
          }
        });
        this.order_type = res.order_type;
        this.thermosphere = res.thermosphere;
        this.humidity = res.humidity;
        this.delivery_method = res.delivery_method;
        this.order_priority_level = res.order_priority_level;
        this.transport_way_List = res.transport_way;
        this.pay_way = payList;
        this.Package_model = res.Package_model; //
      });
    },
    //获取发货人的数据详情
    searchConsignorList(query) {
      this.ruleForm.sender.name = query;
      //获取发货人
      if (query !== "") {
        setTimeout(async () => {
          let result = await getConsignorList({
            branch_id: 1,
            name: query,
            mobile: "",
            customer_id:
              this.ruleForm.customer_id == ""
                ? 0
                : this.ruleForm.customer_id * 1,
          });
          this.consignorList = result.data;
        }, 200);
      } else {
        this.consignorList = [];
      }
    },

    //选择发货人
    selectedConsignor(id) {
      let piece = this.consignorList.find((item) => item.id === id);
      if (piece != undefined) {
        this.ruleForm.sender.phone = piece.mobile; //手机号
        this.ruleForm.sender.address = piece.address; //手机号
        this.ruleForm.begin_longitude = undefined;
        this.ruleForm.begin_latitude = undefined;
        this.ruleForm.addressList = [
          piece.province_id,
          piece.city_id,
          piece.district_id,
        ];
        this.ruleForm.sender.id = piece.id;
        this.ruleForm.sender.name = piece.name;
        this.ruleForm.sender.company = piece.customer_name; //发货公司
        this.sender_company_name = piece.customer_name; //将发货公司重新赋值进行判断
        this.ruleForm.sender.customer_id = piece.customer_id; //发货公司id
        this.sender_company_id = piece.customer_id;
        // this.ruleForm.valid_time = piece.valid_time; //时效
        // if (!this.ruleForm.waybill_product_type) {
        //   this.ruleForm.waybill_product_type = String(
        //     piece.product_type_id == 0 ? "" : piece.product_type_id
        //   ); //承运类型
        //   this.selectTransportsType(piece.product_type_id); //承运类型id
        // }
        this.shiphandleChange(); //发站
      } else {
        this.ruleForm.sender.phone = ""; //手机号
        this.ruleForm.sender.address = ""; //手机号
        this.ruleForm.addressList = [];
        this.ruleForm.sender.id = "";
        this.ruleForm.sender.company = "";
        this.ruleForm.begin_longitude = undefined;
        this.ruleForm.begin_latitude = undefined;
      }
    },
    // 收货人的数据详情
    pageConsigneeInterface(query) {
      this.ruleForm.receiver.name = query;
      //获取收货人
      if (query !== "") {
        setTimeout(async () => {
          let result = await ConsigneeInterface({
            branch_id: 1,
            name: query,
            mobile: "",
            customer_id:
              this.ruleForm.customer_id == ""
                ? 0
                : this.ruleForm.customer_id * 1,
          });
          this.ConsigneeInterfaceList = result.data;
        }, 200);
      } else {
        this.ConsigneeInterfaceList = [];
      }
    },
    //选择货人
    ConsigneeConsignor(id) {
      let piece = this.ConsigneeInterfaceList.find((item) => item.id === id);
      if (piece != undefined) {
        this.ruleForm.receiver.phone = piece.mobile; //手机号
        this.ruleForm.receiver.address = piece.address; //手机号
        this.ruleForm.end_longitude = undefined;
        this.ruleForm.end_latitude = undefined;
        this.ruleForm.receiverList = [
          piece.province_id,
          piece.city_id,
          piece.district_id,
        ];
        this.ruleForm.receiver.id = piece.id;
        this.ruleForm.receiver.name = piece.name;
        this.ruleForm.receiver.company = piece.customer_name;
        this.ruleForm.receiver.customer_id = piece.customer_id;
        this.rechandleChange(); //到站
      } else {
        this.ruleForm.receiver.phone = ""; //手机号
        this.ruleForm.receiver.address = ""; //手机号
        this.ruleForm.receiverList = [];
        this.ruleForm.receiver.id = "";
        this.ruleForm.end_longitude = undefined;
        this.ruleForm.end_latitude = undefined;
      }
    },
    // 发货公司失去焦点判断
    forwarding_unit(event) {
      if (event.target.value != this.sender_company_name) {
        this.ruleForm.sender.customer_id = "0";
      } else {
        this.ruleForm.sender.customer_id = this.sender_company_id;
      }
    },
    // 路由的模糊搜索
    Pageroutername(query) {
      if (query !== "") {
        setTimeout(async () => {
          let result = await routerbox({
            name: query,
          });
          this.routerboxList = result.data;
        }, 200);
      } else {
      }
    },
    // 路由名称
    nounrouter(id) {
      let piece = this.routerboxList.find((item) => item.id === id);
      this.ruleForm.router = piece.name;
      this.ruleForm.router_id = piece.id;
    },
    // 货物数量函数
    addShiper(scope) {
      if(this.isZto){
        this.$message({
          type: "warning",
          message: "当前只允许添加一个货物",
        });
        return;
      }
      this.ruleForm.goods.push({
        name: "", //货物名称
        number: "", //件数
        packing: "", //包装
        weight: "", //重量
        volume: "", //体积
        price: "", //价格
        declared_value: "", //价值
        specification: "", //规格
        commodity_model: "", //模型
        thermosphere: this.goodThermosphere, //温层字段
        package_quantity: "1", //货物件数
        package_type: "", //包装型号
        product_batch: "", //产品批次号
        product_valid_period: "", //产品有效期
        shipment_quantity: "", //发货数量
      });
    },
    reduce(index) {
      // 通过索引删除InForMationList数组中的元素
      // 因为如果不保留唯一一条数据的话再次渲染dom的时候是无法获取数据的
      if (this.ruleForm.goods.length > 1) {
        this.ruleForm.goods.splice(index, 1);
      } else {
        this.$message({
          message: "这是最后一条数据",
          type: "warning",
        });
      }
    },
    // 组织管理页面
    siteListFn() {
      PagewebsiteList("0").then((res) => {
        var res = res.data;
        this.originListData = res;
      });
    },
    siteList() {
      let data = {
        show_employee: false, // 是否展示员工信息
        not_show_first_branch: 1,
      };
      organizationBox(data).then((res) => {
        if (res.code === 10000) {
          this.originList = res.data;
        }
      });
    },
    // 将出发网点赋值
    formConsignor(id) {
      if (this.originList != null) {
        let piece = this.originListData.find((item) => item.id == id);
        if (piece != undefined) {
          this.ruleForm.from_network = piece.name;
        }
      }
    },
    // 目的网点
    ToConsignor(id) {
      if (this.originList != null) {
        let piece = this.originListData.find((item) => item.id == id);
        if (piece != undefined) {
          this.ruleForm.to_network = piece.name;
        }
      }
    },
    // 地址库
    provincectiy() {
      regionList(0).then((res) => {
        this.addresssequence = res.data;
      });
    },
    // 创建接口
    saveadd(formName) {
      // this.addLoading = true;
      this.sender_customer_id();
      this.receiver_customer_id();
      // 返回 出发网点的名字获取
      this.ruleForm.from_network_id != ""
        ? this.formConsignor(
            String(
              this.ruleForm.from_network_id[
                this.ruleForm.from_network_id.length - 1
              ]
            )
          )
        : "";
      // 返回目的网点的名字获取
      this.ruleForm.to_network_id != ""
        ? this.ToConsignor(
            String(
              this.ruleForm.to_network_id[
                this.ruleForm.to_network_id.length - 1
              ]
            )
          )
        : "";
      this.ruleForm.collect_time = {
        start_time: timestamp10(this.ruleForm.value1),
        end_time: "",
      };
      // 处理回单数的
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (
            this.ruleForm.sender.province_name === "暂无省信息" ||
            this.ruleForm.sender.city_name === "暂无市信息" ||
            this.ruleForm.sender.district_name === "暂无区信息" ||
            this.ruleForm.addressList === ["0", "0", "0"]
          ) {
            this.$message({
              message: "请选择发货方的省市区地址",
              type: "error",
            });
            return;
          }
          if (
            this.ruleForm.receiver.province_name === "暂无省信息" ||
            this.ruleForm.receiver.city_name === "暂无市信息" ||
            this.ruleForm.receiver.district_name === "暂无区信息" ||
            this.ruleForm.receiverList === ["0", "0", "0"]
          ) {
            this.$message({
              message: "请选择收货方的省市区地址",
              type: "error",
            });
            return;
          }
          // 处理货物货物信息的钱数
          let data_list = this.cargo_information();
          let customer_id_type = this.ruleForm.customer_id;
          let order_id_id = "";
          if (this.allorderType == "add") {
            order_id_id = "";
          } else if (this.allorderType == "transfer_order") {
            order_id_id = this.id + "";
          }
          let bt_extra_list = {
            supply_company: this.bt_extra.supply_company,
            manufacturer_company: this.bt_extra.manufacturer_company,
            customer_order_no: this.bt_extra.customer_order_no,
            shipment_mode_id: this.bt_extra.shipment_mode_id,
            shipment_mode_name: this.bt_extra.shipment_mode_name,
            shipment_no: this.bt_extra.shipment_no,
            branch_plant_id: this.bt_extra.branch_plant_id,
            branch_plant_name: this.bt_extra.branch_plant_name,
            carrier_id: this.bt_extra.carrier_id,
            carrier_name: this.bt_extra.carrier_name,
            container_id: this.bt_extra.container_id,
            container_number: this.bt_extra.container_number,
            container_no: this.bt_extra.container_no,
            purchaser_id: this.bt_extra.purchaser_id,
            purchaser_name: this.bt_extra.purchaser_name,
            purchaser_address: this.bt_extra.purchaser_address,
            send_to_id: this.bt_extra.send_to_id,
            report_count: this.bt_extra.report_count,
          };
        //     settlement_package_type:"", // 实际结算包装类型
        // settlement_package_quantity:"" // 实际结算包装数量
        let _settlement_package_info=this.ruleForm.settlement_package_info||[]
        let isFill=_settlement_package_info.find(item=>item.settlement_package_type&&iitem.settlement_package_quantity)
        if(!isFill&&!this.is_incubator){
          _settlement_package_info=this.ruleForm.goods.map(item=>{
            return {
              settlement_package_type:item.package_type,
              settlement_package_quantity:item.package_quantity
            }
          })
        }
          var param = {
            handler_id: this.ruleForm.handler_id + "",
            handler_name: this.ruleForm.handler_name,
            order_id: order_id_id,
            source_type: "0",
            customer_id: this.ruleForm.customer_id + "", //所属客户
            // order_no: this.ruleForm.order_no, //运单号
            waybill_number: this.ruleForm.waybill_number, //运单号
            remark: this.ruleForm.remark, //运单备注
            addressList: this.ruleForm.addressList, //发货地址
            receiverList: this.ruleForm.receiverList, //收货地址
            // 发货人
            sender: {
              id: String(
                this.ruleForm.sender.id == 0 ? "" : this.ruleForm.sender.id
              ),
              name: this.ruleForm.sender.name, //发货人名字
              phone: this.ruleForm.sender.phone, //手机号
              address: this.ruleForm.sender.address, //详细地址
              company: this.ruleForm.sender.company, //发货公司
              company_id: String(this.ruleForm.sender.customer_id), //发货公司ID
              province_id: String(this.ruleForm.addressList[0]),
              city_id: String(this.ruleForm.addressList[1]),
              district_id: String(this.ruleForm.addressList[2]),
            },
            // 收货人
            receiver: {
              id: String(
                this.ruleForm.receiver.id == 0 ? "" : this.ruleForm.receiver.id
              ),
              name: this.ruleForm.receiver.name,
              phone: this.ruleForm.receiver.phone,
              company: this.ruleForm.receiver.company,
              company_id: String(this.ruleForm.receiver.customer_id), //收货公司ID
              address: this.ruleForm.receiver.address,
              province_id: String(this.ruleForm.receiverList[0]),
              city_id: String(this.ruleForm.receiverList[1]),
              district_id: String(this.ruleForm.receiverList[2]),
            },
            // 提货时间
            collect_time: {
              start_time: timestamp10(this.ruleForm.value1),
              end_time: "",
            },
            // 货物信息
            goods: data_list.filter(item=>item.is_settlement_info!==1),
            //
            expense: {
              // 运费 提货费 送货费 包装费 手续费 保价费 报价金额 代收货款
              1: String(this.ruleForm.expense[1]), //运费
              8: String(this.ruleForm.expense[8]), //送货费
              5: String(this.ruleForm.expense[5]), //提货费
              6: String(this.ruleForm.expense[6]), //保价费
              9: String(this.ruleForm.expense[9]), //包装费
              4: String(this.ruleForm.expense[4]), //代收货款
              10: String(this.ruleForm.expense[10]), //手续费
              total_freight: String(this.alltotal_cost),
            },
            // 运单类型
            type: String(this.ruleForm.type),
            // 始发网点
            from_network_id: String(
              this.ruleForm.from_network_id[
                this.ruleForm.from_network_id.length - 1
              ]
            ),
            from_network: this.ruleForm.from_network,
            // 目的网点
            to_network_id: String(
              this.ruleForm.to_network_id[
                this.ruleForm.to_network_id.length - 1
              ]
            ),
            to_network: this.ruleForm.to_network,
            // 发站id
            from_region_id: String(this.ruleForm.from_region_id),
            // 发站名字
            from_region: this.ruleForm.from_region,
            // 到站id
            to_region_id: String(this.ruleForm.to_region_id),
            to_region: this.ruleForm.to_region,
            // 路由id
            router_id: String(this.ruleForm.router_id),
            router: this.ruleForm.router,
            // 温度
            thermosphere: this.ruleForm.thermosphere,
            // 湿度
            humidity: this.ruleForm.humidity,
            // 运输方式
            transport_way: this.ruleForm.transport_way,
            // 送货方式
            delivery_method: this.ruleForm.delivery_method,
            // 紧急程度
            priority_level: this.ruleForm.priority_level,
            // 付款
            payment_id: this.ruleForm.payment_id,
            total_freight: this.alltotal_cost,
            // 时效
            aging: String(this.ruleForm.valid_time),
            // 回单数
            receipt_count: String(this.ruleForm.receipt_count),
            // 承运类型
            waybill_product_type: this.ruleForm.waybill_product_type,
            // 图片
            images: this.ruleForm.images,
            // 是否投保
            insure_value: this.ruleForm.insure_value + "",
            // 客户回单
            is_receipt_customer:
              this.ruleForm.is_receipt_customer == true ? "1" : "0",
            // 渡石回单
            is_receipt_ds: this.ruleForm.is_receipt_ds == true ? "1" : "0",
            bt_extra: customer_id_type == 18323 ? bt_extra_list : null,
            begin_longitude: this.ruleForm.begin_longitude,
            begin_latitude: this.ruleForm.begin_latitude,
            end_longitude: this.ruleForm.end_longitude,
            end_latitude: this.ruleForm.end_latitude,
            distance: this.ruleForm.distance,
            zto_receipt_type:this.ruleForm.zto_receipt_type,
            // 中通新增送货方式
            zto_delivery_type:this.ruleForm.zto_delivery_type,
            // 中通新增物品类别
            zto_item_type:this.ruleForm.zto_item_type,
            // 中通新增货物类型
            zto_goods_category:this.ruleForm.zto_goods_category,
            agent_collection:this.ruleForm.agent_collection,
            settlement_package_info:_settlement_package_info,
          };

          WaybillAddFn(param).then((res) => {
            if (res && res.code == "10000") {
              this.$message({
                message: "创建成功",
                type: "success",
              });
              // this.addLoading = false;
              this.orderclose();
              // location.reload()
            } else {
              // this.addLoading = false;
            }
          });
        } else {
          return false;
        }
      });
    },
    // 修改接口
    upadateadd(formName) {
      this.ruleForm.from_network_id != ""
        ? this.formConsignor(
            String(
              this.ruleForm.from_network_id[
                this.ruleForm.from_network_id.length - 1
              ]
            )
          )
        : "";
      this.ruleForm.to_network_id != ""
        ? this.ToConsignor(
            String(
              this.ruleForm.to_network_id[
                this.ruleForm.to_network_id.length - 1
              ]
            )
          )
        : "";
      this.ruleForm.collect_time = {
        start_time: timestamp10(this.ruleForm.value1),
        end_time: "",
      };
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.updateLoading = true;
          if (
            this.ruleForm.sender.province_name === "暂无省信息" ||
            this.ruleForm.sender.city_name === "暂无市信息" ||
            this.ruleForm.sender.district_name === "暂无区信息" ||
            this.ruleForm.addressList.includes(0)
          ) {
            this.$message({
              message: "请选择发货方的省市区地址",
              type: "error",
            });
            return;
          }
          if (
            this.ruleForm.receiver.province_name === "暂无省信息" ||
            this.ruleForm.receiver.city_name === "暂无市信息" ||
            this.ruleForm.receiver.district_name === "暂无区信息" ||
            this.ruleForm.receiverList.includes(0)
          ) {
            this.$message({
              message: "请选择收货方的省市区地址",
              type: "error",
            });
            return;
          }
          // 处理货物的计算
          let data_list = this.cargo_information();
          let customer_id_type = this.ruleForm.customer_id;
          let bt_extra_list = {
            supply_company: this.bt_extra.supply_company,
            manufacturer_company: this.bt_extra.manufacturer_company,
            customer_order_no: this.bt_extra.customer_order_no,
            shipment_mode_id: this.bt_extra.shipment_mode_id,
            shipment_mode_name: this.bt_extra.shipment_mode_name,
            shipment_no: this.bt_extra.shipment_no,
            branch_plant_id: this.bt_extra.branch_plant_id,
            branch_plant_name: this.bt_extra.branch_plant_name,
            carrier_id: this.bt_extra.carrier_id,
            carrier_name: this.bt_extra.carrier_name,
            container_id: this.bt_extra.container_id,
            container_number: this.bt_extra.container_number,
            container_no: this.bt_extra.container_no,
            purchaser_id: this.bt_extra.purchaser_id,
            purchaser_name: this.bt_extra.purchaser_name,
            purchaser_address: this.bt_extra.purchaser_address,
            send_to_id: this.bt_extra.send_to_id,
            report_count: this.bt_extra.report_count,
          };
          var param = {
            id: this.id + "",
            handler_id: this.ruleForm.handler_id + "",
            handler_name: this.ruleForm.handler_name,
            customer_id: this.ruleForm.customer_id + "", //所属客户
            waybill_number: this.ruleForm.waybill_number, //运单号
            remark: this.ruleForm.remark, //运单备注
            addressList: this.ruleForm.addressList, //发货地址
            receiverList: this.ruleForm.receiverList, //收货地址
            // 发货人
            sender: {
              id: String(
                this.ruleForm.sender.id == 0 ? "" : this.ruleForm.sender.id
              ),
              name: String(this.ruleForm.sender.name), //发货人名字
              phone: this.ruleForm.sender.phone, //手机号
              address: this.ruleForm.sender.address, //详细地址
              company: this.ruleForm.sender.company, //发货公司
              company_id: String(this.ruleForm.sender.customer_id), //发货公司ID
              province_id: String(this.ruleForm.addressList[0]),
              city_id: String(this.ruleForm.addressList[1]),
              district_id: String(this.ruleForm.addressList[2]),
            },
            // 收货人
            receiver: {
              id: String(
                this.ruleForm.receiver.id == 0 ? "" : this.ruleForm.receiver.id
              ),
              name: String(this.ruleForm.receiver.name),
              phone: this.ruleForm.receiver.phone,
              company: this.ruleForm.receiver.company,
              company_id: String(this.ruleForm.receiver.customer_id), //收货公司ID
              address: this.ruleForm.receiver.address,
              province_id: String(this.ruleForm.receiverList[0]),
              city_id: String(this.ruleForm.receiverList[1]),
              district_id: String(this.ruleForm.receiverList[2]),
            },
            // 提货时间
            collect_time: {
              start_time: timestamp10(this.ruleForm.value1),
              end_time: "",
            },
            // 货物信息

            goods: data_list.filter(item=>item.is_settlement_info!==1),
            //
            expense: {
              // 运费 提货费 送货费 包装费 手续费 保价费 报价金额 代收货款
              1: String(this.ruleForm.expense[1]), //运费
              8: String(this.ruleForm.expense[8]), //送货费
              5: String(this.ruleForm.expense[5]), //提货费
              6: String(this.ruleForm.expense[6]), //保价费
              9: String(this.ruleForm.expense[9]), //包装费
              4: String(this.ruleForm.expense[4]), //代收货款
              10: String(this.ruleForm.expense[10]), //手续费
              total_freight: String(this.alltotal_cost),
            },
            // 运单类型
            type: String(this.ruleForm.type),
            // 始发网点
            from_network_id: String(
              this.ruleForm.from_network_id[
                this.ruleForm.from_network_id.length - 1
              ]
            ),
            from_network: this.ruleForm.from_network,
            // 目的网点
            to_network_id: String(
              this.ruleForm.to_network_id[
                this.ruleForm.to_network_id.length - 1
              ]
            ),
            to_network: this.ruleForm.to_network,
            // 发站id
            from_region_id: String(this.ruleForm.from_region_id),
            // 发站名字
            from_region: this.ruleForm.from_region,
            // 到站id
            to_region_id: String(this.ruleForm.to_region_id),
            to_region: this.ruleForm.to_region,
            // 路由id
            router_id: String(this.ruleForm.router_id),
            router: String(this.ruleForm.router),
            // 温度
            thermosphere: this.ruleForm.thermosphere,
            // 湿度
            humidity: this.ruleForm.humidity,
            // 运输方式
            transport_way: this.ruleForm.transport_way,
            // 送货方式
            delivery_method: this.ruleForm.delivery_method,
            // 紧急程度
            priority_level: this.ruleForm.priority_level,
            // 付款
            payment_id: this.ruleForm.payment_id,
            total_freight: this.alltotal_cost,
            // 回单数
            receipt_count: String(this.ruleForm.receipt_count),
            // 承运类型
            waybill_product_type: this.ruleForm.waybill_product_type,
            // 图片
            images: this.ruleForm.images,
            // 是否投保
            insure_value: this.ruleForm.insure_value + "",
            // 时效
            aging: String(this.ruleForm.valid_time),
            // 客户回单
            is_receipt_customer:
              this.ruleForm.is_receipt_customer == true ? "1" : "0",
            // 渡石回单
            is_receipt_ds: this.ruleForm.is_receipt_ds == true ? "1" : "0",
            bt_extra: customer_id_type == 18323 ? bt_extra_list : {},
            begin_longitude: this.ruleForm.begin_longitude,
            begin_latitude: this.ruleForm.begin_latitude,
            end_longitude: this.ruleForm.end_longitude,
            end_latitude: this.ruleForm.end_latitude,
            distance: this.ruleForm.distance,
            zto_receipt_type:this.ruleForm.zto_receipt_type,
            // 中通新增送货方式
            zto_delivery_type:this.ruleForm.zto_delivery_type,
            // 中通新增物品类别
            zto_item_type:this.ruleForm.zto_item_type,
            // 中通新增货物类型
            zto_goods_category:this.ruleForm.zto_goods_category,
            agent_collection:this.ruleForm.agent_collection,
            settlement_package_info:this.ruleForm.settlement_package_info,
          };
          WaybillEditFn(param).then((res) => {
            if (res && res.code == "10000") {
              this.$message({
                message: "修改成功",
                type: "success",
              });
              this.orderclose();
              this.Pageorder_details();
              this.updateLoading = false;
              if (this.Typeinformation) {
                this.allorderType = "onlyread";
                this.disabled_value = true;
              }
            } else if (res && res.code == "21251") {
              this.$confirm("已创建配送单，配送方式改为自提将删除配送单", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              })
                .then(() => {
                  console.log("删除函数调用");
                  this.deletewaybill();
                  // this.$message({
                  //   type: 'success',
                  //   message: '删除成功!'
                  // });
                  this.updateLoading = false;
                })
                .catch(() => {
                  console.log("非删除");
                  // this.$message({
                  //   type: 'info',
                  //   message: '已取消删除'
                  // });
                  this.updateLoading = false;
                });
            } else {
              this.updateLoading = false;
            }
          });
        } else {
          return false;
        }
      });
    },
    // 处理货物信息接口*100
    cargo_information() {
      let data = JSON.parse(JSON.stringify(this.ruleForm.goods));
      data.forEach((res) => {
        res.number = String(res.number);
        res.weight = String(res.weight);
        res.volume = String(res.volume);
        res.price = String(res.price);
        res.declared_value = String(res.declared_value);
        res.product_valid_period = timestamp10(res.product_valid_period);
      });
      return data;
    },
    // 回显货物信息接口/100
    method_information(goods) {
      goods.forEach((res) => {
        res.weight = String(res.weight);
        res.volume = String(res.volume);
        res.price = String(res.price);
        res.declared_value = String(res.declared_value);
        res.package_type = res.package_type == "0" ? " " : res.package_type;
        res.product_valid_period = 1673339389000;
      });
      return goods;
    },

    // 运单详情
    Pageorder_details() {
      var param = {
        id: this.id + "",
      };
      let DetailData = "";
      if (this.wayType == "onlyread" || this.wayType == "modify") {
        DetailData = WaybillDetailFn;
      } else if (this.wayType == "transfer_order") {
        DetailData = order_details;
      }
      DetailData(param).then((res) => {
        var res = res.data;
        // 将数据除以100
        var goodmethod = this.method_information(res.goods);
        this.ruleForm.status = res.status;
        this.showPaymentBtn =
          res.status >= 2 && (res.payment_id === "1" || res.payment_id === "6");
        this.ruleForm.pay_status = res.pay_status;
        this.ruleForm.customer_id = res.customer_id;
        this.searchCustomerid(res.customer_id);
        if (this.wayType == "onlyread" || this.wayType == "modify") {
          this.ruleForm.waybill_number = res.waybill_number; //运单号
        } else if (this.wayType == "transfer_order") {
          this.ruleForm.waybill_number = res.order_no; //运单号
        }
        this.ruleForm.remark = res.remark; //运单备注
        this.ruleForm.addressList = res.addressList; //发货地址
        this.ruleForm.receiverList = res.receiverList; //收货地址
        // 发货人
        this.ruleForm.sender.id = res.sender.id;
        this.ruleForm.sender.name = res.sender.name;
        (this.ruleForm.customer_id = res.customer_id * 1), //所属客户
          this.searchConsignorList(res.sender.name);
        this.ruleForm.sender.phone = res.sender.phone;
        this.ruleForm.sender.address = res.sender.address;
        this.ruleForm.sender.company = res.sender.company;
        this.ruleForm.sender.customer_id = Number(res.sender.company_id);
        this.ruleForm.addressList = [
          Number(res.sender.province_id),
          Number(res.sender.city_id),
          Number(res.sender.district_id),
        ];
        this.ruleForm.sender.province_name = res.sender.province_name;
        this.ruleForm.sender.city_name = res.sender.city_name;
        this.ruleForm.sender.district_name = res.sender.district_name;
        // 收货人
        this.ruleForm.receiver.id = res.receiver.id;
        this.ruleForm.receiver.name = res.receiver.name;
        this.pageConsigneeInterface(res.receiver.name);
        this.ruleForm.receiver.phone = res.receiver.phone;
        this.ruleForm.receiver.company = res.receiver.company;
        this.ruleForm.receiver.customer_id = Number(res.receiver.company_id);
        this.ruleForm.receiver.address = res.receiver.address;
        this.ruleForm.receiverList = [
          Number(res.receiver.province_id),
          Number(res.receiver.city_id),
          Number(res.receiver.district_id),
        ];
        this.ruleForm.receiver.province_name = res.receiver.province_name;
        this.ruleForm.receiver.city_name = res.receiver.city_name;
        this.ruleForm.receiver.district_name = res.receiver.district_name;

        // 提货时间
        this.ruleForm.value1 =
          res.collect_time.start_time == "0"
            ? ""
            : Number(res.collect_time.start_time * 1000);
        // 货物信息
        this.ruleForm.goods = goodmethod;

        // 运费 提货费 送货费 包装费 手续费 保价费 报价金额 代收货款
        if (res.expense != null) {
          this.ruleForm.expense[1] =
            res.expense[1] == undefined ? 0 : res.expense[1] * 1;
          this.ruleForm.expense[8] =
            res.expense[8] == undefined ? 0 : res.expense[8] * 1;
          this.ruleForm.expense[5] =
            res.expense[5] == undefined ? 0 : res.expense[5] * 1;
          this.ruleForm.expense[6] =
            res.expense[6] == undefined ? 0 : res.expense[6] * 1;
          this.ruleForm.expense[9] =
            res.expense[9] == undefined ? 0 : res.expense[9] * 1;
          this.ruleForm.expense[4] =
            res.expense[4] == undefined ? 0 : res.expense[4] * 1;
          this.ruleForm.expense[10] =
            res.expense[10] == undefined ? 0 : res.expense[10] * 1;
        } else {
        }
        // 运单类型
        this.ruleForm.type = res.type;
        // 始发网点
        this.ruleForm.from_network_id =
          res.from_network_id == "0" ? "" : Number(res.from_network_id);
        this.ruleForm.from_network_name = res.from_network_name;
        // 目的网点
        this.ruleForm.to_network_id =
          res.to_network_id == "0" ? "" : Number(res.to_network_id);
        this.ruleForm.to_network_name = res.to_network_name;
        // 发站id
        this.ruleForm.from_region_id = res.from_region_id;
        // 发站名字
        this.ruleForm.from_region = res.from_region;
        // 到站id
        this.ruleForm.to_region_id = res.to_region_id;
        this.ruleForm.to_region = res.to_region;
        // 路由id
        this.ruleForm.router_id = res.router_id;
        this.ruleForm.router = res.router;
        // 温度
        this.ruleForm.thermosphere =
          res.thermosphere == 0 ? "" : res.thermosphere;
        // 湿度
        this.ruleForm.humidity = res.humidity;
        // 运输方式
        this.ruleForm.transport_way = res.transport_way;
        // 送货方式
        this.ruleForm.delivery_method = res.delivery_method;
        // 紧急程度
        this.ruleForm.priority_level = res.priority_level;
        // 付款方式
        this.ruleForm.payment_id = res.payment_id;

        // 回单数
        (this.ruleForm.is_receipt_customer =
          res.is_receipt_customer > 0 ? true : false),
          (this.ruleForm.is_receipt_ds = res.is_receipt_ds > 0 ? true : false),
          // 投保
          (this.ruleForm.insure_value = res.insure_value * 1);
        // 承运类型
        this.ruleForm.waybill_product_type =
          res.waybill_product_type == 0 ? "" : res.waybill_product_type;
        this.selectTransportsType(res.waybill_product_type, "2"); //详情
        // 时效
        this.ruleForm.valid_time = res.aging;
        // 预计签收时间
        this.ruleForm.expected_signing_time = res.expected_signing_time;
        // 百特装运单信息orderclose
        this.bt_extra = res.bt_extra == null ? {} : res.bt_extra;
        // 创建人
        this.nickname = res.last_editor_name;
        // 创建时间
        this.create_time = new Date(res.create_time * 1000);
        // 随货同行单
        //
        if (res.images) {
          this.ruleForm.images = res.images;
          this.fileList = res.images.map((url) => {
            return url;
          });
        } else {
          this.fileList = [];
        }
        this.ruleForm.begin_longitude = res.begin_longitude;
        this.ruleForm.begin_latitude = res.begin_latitude;
        this.ruleForm.end_longitude = res.end_longitude;
        this.ruleForm.end_latitude = res.end_latitude;
        this.ruleForm.distance = res.distance;
        this.ruleForm.zto_receipt_type= res.zto_receipt_type,
        this.ruleForm.zto_delivery_type= res.zto_delivery_type,
        this.ruleForm.zto_item_type= res.zto_item_type,
        this.ruleForm.zto_goods_category= res.zto_goods_category
        this.ruleForm.agent_collection= res.agent_collection
        this.ruleForm.settlement_package_info= res.settlement_package_info
      });
    },
    // 关闭页面
    orderclose() {
      if (this.allorderType == "transfer_order") {
        this.$parent.allorderClose();
      } else {
        if (this.$parent.WaybillClose) {
          this.$parent.WaybillClose();
        } else {
          this.$emit("close");
        }
      }
    },
    // 修改页面
    changedclose() {
      this.Objwaybill_order_edit_status();
      this.disabled_value = false;
      this.allorderType = "modify";
    },
    // 上传的功能
    beforeRemove(file, fileList) {
      return this.$confirm("是否删除该图片");
    },
    handlePreview(file) {
      const regex = /\.(jpg|png|webp|jpeg)$/i;
      if (regex.test(file.url)||file.url.indexOf('blob:')==0) {
        this.$viewerApi({
          images: [file.url],
        });
      } else {
        window.open(file.url);
      }
      // this.dialogImageUrl = file.url;
      // this.dialogVisible = true;
    },
    handleRemove(file, fileList) {
      const index = this.ruleForm.images.findIndex(
        (item) => item.uid === file.uid
      );
      index > -1 && this.ruleForm.images.splice(index, 1);
    },
    handleChange(file, fileList, type) {
      this.fileList = fileList;
      var filelist = file.raw; //文件
      var filename = file.raw.uid + file.raw.name; //通过 uid和name组成文件的名字
      uploading(filelist, filename, type).then((res) => {
        this.ruleForm.images.push({
          type: "0",
          uid: file.uid,
          url: res.res.requestUrls[0],
        });
      });
    },
    //限制只能输入几位小数
    controlInputNumber(value, num, ...args) {
      //(输入的需要做限制的属性,做几位小数的限制,属性名)
      if (num === 2) {
        switch (args.length) {
          case 1:
            this[args[0]] = filterTwoNumber(value);
            break;
          case 2:
            this[args[0]][args[1]] = filterTwoNumber(value);
            break;
          case 3:
            this[args[0]][args[1]][args[2]] = filterTwoNumber(value);
            break;
          case 4:
            this[args[0]][args[1]][args[2]][args[3]] = filterTwoNumber(value);
            break;
        }
      } else if (num === 3) {
        switch (args.length) {
          case 1:
            this[args[0]] = filterThreeNumber(value);
            break;
          case 2:
            this[args[0]][args[1]] = filterThreeNumber(value);
            break;
          case 3:
            this[args[0]][args[1]][args[2]] = filterThreeNumber(value);
            break;
          case 4:
            this[args[0]][args[1]][args[2]][args[3]] = filterTwoNumber(value);
            break;
        }
      }
    },
    // 监听承运类型计算匹配规则
    watchwaybill(newname, oldName) {
      this.pageaccountingrules(1, "val");
    },
    // 监听所属客户来计算匹配规则
    watchcustomer(newname, oldName) {
      this.pageaccountingrules(1, "val");
    },
    // 计费规则接口
    pageaccountingrules(type, val) {
      if (
        this.ruleForm.waybill_product_type != "" &&
        this.ruleForm.customer_id != "" &&
        this.ruleForm.customer_id != 18323
      ) {
        this.ruleForm.goods.forEach((item) => {
          item.number = String(item.number);
        });
        // 计费规则调用
        var param = {
          node: "9", // 当前节点
          transport_type_id: this.ruleForm.waybill_product_type + "", // 承运类型
          start_area_info: {
            address: this.ruleForm.sender.address,
            province_id: this.ruleForm.addressList[0], // 省id
            city_id: this.ruleForm.addressList[1], // 市id
            district: this.ruleForm.addressList[2], // 区id
          }, // 出发区域信息
          end_area_info: {
            address: this.ruleForm.receiver.address,
            province_id: this.ruleForm.receiverList[0], // 省id
            city_id: this.ruleForm.receiverList[1], // 市id
            district: this.ruleForm.receiverList[2], // 区id
          }, // 到达区域信息
          customer_id: this.ruleForm.customer_id + "", // 客户id
          carrier_id: "", // 承运商id
          goods_list: this.ruleForm.goods.filter(item=>item.is_settlement_info!==1),
          settlement_package_list:this.ruleForm.settlement_package_info
        };
        setTimeout(async () => {
          let result = await accountingrules(param);
          let datalist = JSON.parse(JSON.stringify(result.data));
          if (type == 1) {
            this.ruleForm.goods = datalist;
            this.disposerule(datalist);
          } else if (type == 2) {
            if (datalist[val.$index].rule_cost_info&&datalist[val.$index].rule_cost_info.length == 1) {
              // 当规则只有一条的时候赋值
              this.ruleForm.goods.splice(val.$index, 1, datalist[val.$index]);
              this.$set(
                this.ruleForm.goods[val.$index],
                "rule_cost_info_id",
                datalist[val.$index].rule_cost_info[0].rule_id
              );
              this.rulechange(
                val,
                datalist[val.$index].rule_cost_info,
                datalist[val.$index].rule_cost_info[0].rule_id
              );
            } else {
              this.ruleForm.goods.splice(val.$index, 1, datalist[val.$index]);
            }
          }
        }, 200);
      }
    },
    // 货物改变
    accopNumber(type, val) {
      this.pageaccountingrules(type, val);
    },
    rulechange(valrow, valuepice, value) {
      if (value != "") {
        var piceList = {};
        valuepice.forEach((element) => {
          if (element.rule_id == value) {
            piceList = element;
          }
        });
        this.ruleForm.goods[valrow.$index].price = piceList.cost + "";
        this.AllShowprice();
      } else {
        this.ruleForm.goods[valrow.$index].price = 0 + "";
        this.AllShowprice();
      }
    },
    // 最后的运费价格
    AllShowprice() {
      var allpice = 0;
      for (var i = 0; i < this.ruleForm.goods.length; i++) {
        allpice = allpice + this.ruleForm.goods[i].price * 1;
      }
      if(this.wayType == "onlyread"||this.wayType=="modify"){
        this.advicePrice = allpice
      }else{
        this.ruleForm.expense[1] = allpice;
      }
    },
    // 赋值计费规则
    disposerule(value) {
      for (let index = 0; index < value.length; index++) {
        if (value[index].rule_cost_info&&value[index].rule_cost_info.length == 1) {
          this.$set(
            this.ruleForm.goods[index],
            "rule_cost_info_id",
            value[index].rule_cost_info[0].rule_id
          );
          
        } else {
          this.$set(this.ruleForm.goods[index], "rule_cost_info_id", "");
        }
        this.rulechange(
                {$index:index},
                value[index].rule_cost_info,
                this.ruleForm.goods[index].rule_cost_info_id
              );
      }

    },
    Objwaybill_order_edit_status() {
      console.log("函数的调用Objwaybill_order_edit_status");
      var param = {
        order_id: "", // 查订单传订单id
        waybill_id: this.id + "", // 查运单传运单id
      };
      waybill_order_edit_status(param).then((res) => {
        if (res.code == 10000) {
          console.log(res.data.status, "jfalskdjflakjsd");
          if (res.data.status == 1) {
            this.waybill_order_status = true;
          } else {
            this.waybill_order_status = false;
          }
        }
      });
    },
    // 根据接口读提货时间是否必填
    changeRequired() {
      CollectTimeControl({}).then((res) => {
        if (res.code === 10000) {
          const data = res.data;
          this.rules["value1"][0].required =
            data.switch_status === "1" ? true : false;
        }
      });
    },
    async getRequiredField() {
      let result = await reqRequiredField({
        item_names: ["waybill_branch_edit"],
      });
      this.required_setting_list = result.data.setting_list;
    },
    async openPayment() {
      this.toPaymentLoading = true;
      let res = await WaybillWxPayQrcode({
        order_id: 0,
        waybill_id: this.id * 1,
      });
      if (!res) {
        this.toPaymentLoading = false;
      } else {
        this.qrcodeUrl = res.data.code_data;
        this.paymentQrcodeVisible = true;
        let result;
        this.timer = setInterval(async () => {
          result = await WaybillPaymentStatus({ waybill_id: this.id * 1 });
          if (result.data.status === 1) {
            this.toPaymentLoading = false;
            clearTimeout(this.timer);
            this.paySuccess = true;
          }
        }, 2000);
      }
    },
    closeQrcode() {
      clearTimeout(this.timer);
      this.paySuccess = false;
      this.paymentQrcodeVisible = false;
      setTimeout(() => {
        this.Pageorder_details();
      }, 1000);
    },
    async confirmRefund() {
      if (!this.refundValue.remark) {
        this.$message({
          message: "退款备注必填!",
          type: "error",
        });
        return;
      }
      this.refundValue.waybill_id = this.id * 1;
      this.refundValue.refund_time = (this.createTime + "").slice(0, 10) * 1;
      let res = await reqRefund(this.refundValue);
      if (res.code !== 10000) {
        this.$message({
          message: res.message,
          type: "warning",
        });
      } else {
        this.$message({
          message: "退款成功",
          type: "success",
        });
        this.refundVisible = false;
        this.refundConfirmVisible = false;
        setTimeout(() => {
          this.Pageorder_details();
        }, 1000);
      }
    },
    // 删除的配送单函数
    deletewaybill() {
      var param = {
        id: this.id,
      };
      distributionBatchList(param).then((res) => {
        if (res.code == 10000) {
          console.log(res.data);
          if (res.data) {
            var param = {
              ids: [res.data[0].id * 1],
            };
            DistributionDeleteFn(param).then((res) => {
              if (res.code == 10000) {
                this.$message({
                  message: "修改成功",
                  type: "success",
                });
              }
            });
          }
        }
      });
    },
    //Notification 通知事件
    NotificationObj() {
      console.log("函数调用");
      // 数据改变
      (this.noTifyData = {
        customer_id: this.ruleForm.customer_id + "",
        product_type_id: this.ruleForm.waybill_product_type,
        node_id: "",
      }),
        (this.notifyType = true);
    },
  },
  async mounted() {
    this.getRequiredField();
    if (this.$store.state.user.setting_list[0].item_value == 0) {
      this.setting_list_type = true;
    } else {
      this.setting_list_type = false;
    }
    this.siteList(); //组织
    this.siteListFn();
    this.provincectiy(); //地址
    await this.pagegetTransportsList(); //产品类型
    this.locationcustore();
    this.getHandlersList();
    this.changeRequired();
    this.pagedictionanryList(); //数据字典
    // 通过vuex中的type来判断是修改创建修改和详情 新增是add,详情是onlyread,修改是modify
    if (this.wayType == "add") {
      this.allorderType = "add";
    } else if (this.wayType == "onlyread") {
      this.allorderType = "onlyread";
      this.Pageorder_details();
      this.disabled_value = true;
    } else if (this.wayType == "transfer_order") {
      this.allorderType = "transfer_order";
      this.Pageorder_details();
    } else if (this.wayType == "modify") {
      this.allorderType = "modify";
      // this.Objwaybill_order_edit_status()//当运单转单后的编辑权限
      this.Pageorder_details();
    }
  },
};
</script>

  <style lang="less" scoped >
input::-webkit-input-placeholder {
  color: #ccc;
  font-size: 10px;
}

input::-moz-input-placeholder {
  color: #ccc;
  font-size: 10px;
}

input::-ms-input-placeholder {
  color: #ccc;
  font-size: 10px;
}
/deep/ .el-upload--picture-card,
/deep/ .el-upload-list__item {
  width: 100px;
  height: 100px;
  line-height: 110px;
}

/deep/ .el-dialog--center .el-dialog__body {
  text-align: center;
  padding-top: 10px;
}

.creation {
  width: 100%;
  background: white;
  position: absolute;
  right: 0px;
  top: 0px;
  z-index: 100;
  overflow: hidden;
}
.creation_one {
}
// 头部信息
.header {
  width: 100%;
  height: 36px;
  background: #f5f7fa;
  line-height: 36px;

  .order-title {
    color: #101010;
    font-size: 14px;
    padding: 0 12px;
    cursor: pointer;
  }

  .order-right {
    position: absolute;
    right: 0;
    top: 0;
    height: 35px;
    line-height: 35px;

    .order-close {
      height: 35px;
      display: inline-erblock;
      overflow: hidden;
      position: relative;
      padding: 0 10px;
      cursor: pointer;
      color: #fff;
    }
  }
}

// 底部信息
.footer {
  // position: absolute;
  width: 86.3%;
  height: 10px;
  background: #f8f8f8;
  z-index: 100;
  bottom: 0px;
}

// 显示打印框的内容

// 内容部分
.article {
  width: 98%;
  height: calc(100vh - 65px);
  overflow: auto;
  margin: 10px auto;
  padding: 0px 11px 0px 0px;
}
.article_one {
}
.demo-ruleForm {
  margin-bottom: 60px;
}
// 设置输入框格式
.order-shiper-unit {
  // width: 99.5%;
  height: 25px;
  margin-top: 5px;

  display: flex;

  label {
    width: 70px;
    text-align: justify;
    text-align-last: justify;
    display: block;
    font-size: 10px;
    padding: 5px;
  }

  input {
    margin-top: 4px;
    border: none;
    border-bottom: 1px solid black;
  }
}

// 输入框内部的头部格式
.order-shiper-header {
  width: 100%;
  height: 26px;
  background: darkorange;
  line-height: 26px;

  span {
    margin-left: 10px;
    font-size: 13px;
    color: white;
  }

  i {
    color: white;
    font-size: 10px;
    margin-left: 5%;
  }
}

// 运单号
.order-content {
  width: 99.7%;
  background: white;
  padding: 10px 0px 0px 0px;
  display: flex;
  flex-wrap: wrap;
  border: 1px solid #e99d42;
}

// 发货方
.order-cargo {
  margin-top: 10px;
  display: flex;
  flex-direction: row;
  // 发货人
  .order-shiper {
    width: 49.5%;
    height: 100%;
    border: 1px solid #e69850;
  }
  // 收货人
  .order-delivery {
    width: 49.5%;
    height: 100%;
    margin-left: auto;
    border: 1px solid #e69850;
  }
}

// 货物信息
.order-information {
  margin-top: 10px;
  border: 1px solid #e69850;
  .order-shiper-img {
    width: 100%;
  }
  .order-shiper-warp {
    .goods-info-table {
      width: 100%;
      border: 1px solid black;
      height: 30px;
      text-align: center;
      border-collapse: collapse;

      tr {
        // border: 1px solid black;
        td {
          width: 30px;
          border: 1px solid black;
        }
      }
    }

    .remodername .number {
      height: 20px;
      display: block;
    }

    .remodername:hover .number {
      display: none;
    }

    .remodername .remodercenter {
      display: none;
      color: #161414;
    }

    .remodername:hover .remodercenter {
      height: 20px;
      display: block;
      color: #262424;
    }
  }
  /deep/.form-thero {
    .el-form-item__content {
      margin-left: 0px !important;
    }
  }
}

// 运单信息
.order-inter {
  margin-top: 10px;
  border: 1px solid #e69850;
  padding-bottom: 10px;

  .order-inter-message {
    margin-top: 12px;
    // display: flex;
    flex-wrap: wrap;
  }
}

// 温度湿度信息
.order-temperature {
  margin-top: 10px;
  border: 1px solid #e69850;

  .order-inter-message {
    padding: 0px 0px 0px 12px;
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
  }
}

// 增值服务
.order-appreciation {
  margin-top: 10px;
  border: 1px solid #e69850;

  .order-inter-message {
    padding: 10px 0px 0px 0px;
    // margin-top: 12px;
    // display: flex;
    // flex-wrap: wrap;
  }
}

// 合计运费
.order-freight {
  margin-top: 10px;
  border: 1px solid #e69850;
  // padding-bottom: 6px;
  // margin-bottom: 38px;
  .order-inter-message {
    display: flex;
    .order-inter-message_right {
      width: 75%;
      padding: 10px 0px 0px 0px;
      border-right: 1px solid #e69850;
    }
    .order-inter-message_left {
      padding: 10px 0px 0px 0px;
      /* width: 20%; */
    }
  }
}
</style>
